chenxin
2020-10-28 c99b622ec5db9282d6466b106558f840a9a21610
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
 
namespace TowerDefense.UI
{
    /// <summary>
    /// A button for exiting the game
    /// </summary>
    public class ExitButton : Button
    {
        /// <summary>
        /// Close the game when this button is clicked
        /// </summary>
        public override void OnPointerClick(PointerEventData eventData)
        {
            Application.Quit();
        }
 
        /// <summary>
        /// Disable this button on mobile platforms
        /// </summary>
        protected override void Awake()
        {
            base.Awake();
 
#if UNITY_ANDROID || UNITY_IOS
            if (Application.isPlaying)
            {
                gameObject.SetActive(false);
            }
#endif
        }
    }
}