using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace SC.Tools.UpdateAPKSystem { public class UseUpdateAPKDemo : MonoBehaviour { /// /// 开启app后等待多少时间开始检测 /// [Header("开启检测的延迟")] [SerializeField] private float waittingTime = 0; Coroutine WaitCoroutine; /// /// 绑定的3D按键 可空 /// [Header("绑定的3D按键 可空")] public SCButton Button3D; /// /// 绑定的2D UI按键 可空 /// [Header("绑定的2D UI按键 可空")] public Button ButtonUI; static UseUpdateAPKDemo instant; void Awake() { if (instant) { DestroyImmediate(gameObject); return; } instant = this; DontDestroyOnLoad(gameObject); } void Start() { WaitCoroutine = StartCoroutine(Waitting(waittingTime)); if (Button3D) { Button3D.onClick.AddListener(OnPointerClick); } if (ButtonUI) { ButtonUI.onClick.AddListener(OnPointerClick); } } void Disable() { if (Button3D) { Button3D.onClick.RemoveListener(OnPointerClick); } if (ButtonUI) { ButtonUI.onClick.RemoveListener(OnPointerClick); } if (WaitCoroutine != null) { StopCoroutine(Waitting(waittingTime)); } } IEnumerator Waitting(float time = 0) { while (true) { if (time != 0) { yield return new WaitForSeconds(time); } yield return null; if (SvrManager.Instance && SvrManager.Instance.IsRunning) { UpdateAPKSystem.getInstant.RunSilent(); yield break; } } } public void OnPointerClick() { UpdateAPKSystem.getInstant.Run(); } } }