123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- namespace SC.Tools.UpdateAPKSystem {
- public class UseUpdateAPKDemo : MonoBehaviour
- {
- /// <summary>
- /// 开启app后等待多少时间开始检测
- /// </summary>
- [Header("开启检测的延迟")]
- [SerializeField]
- private float waittingTime = 0;
- Coroutine WaitCoroutine;
- /// <summary>
- /// 绑定的3D按键 可空
- /// </summary>
- [Header("绑定的3D按键 可空")]
- public SCButton Button3D;
- /// <summary>
- /// 绑定的2D UI按键 可空
- /// </summary>
- [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();
- }
- }
- }
|