using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using SC; public class ResetView : MonoBehaviour { [SerializeField] private UIButton ResetBtn;//重置场景的按钮 [SerializeField] private UIButton OpenVufoiraBtn;//开启扫描 [SerializeField] private UIButton CloseVufoiraBtn;//关闭扫描 [SerializeField] private UIButton ExitBtn;//退出的按钮 void Start () { ResetBtn.onClick.AddListener(ResetClickBtn); ExitBtn.onClick.AddListener(ExitClickBtn); ExitBtn.gameObject.SetActive(false); if (OpenVufoiraBtn!= null) OpenVufoiraBtn.onClick.AddListener(OpenVufoiraClick); if (CloseVufoiraBtn != null) { CloseVufoiraBtn.gameObject.SetActive(false); CloseVufoiraBtn.onClick.AddListener(CloseVufoiraClick); } if(OpenVufoiraBtn != null) OpenVufoiraBtn.gameObject.SetActive(false); if(CloseVufoiraBtn != null) CloseVufoiraBtn.gameObject.SetActive(false); MessageCenterController.Instance.Register(GameEnum.MESSAGE_ENTER_COURSE, ShowEffect);//进入房间 MessageCenterController.Instance.Register(GameEnum.MESSAGE_EXIT_COURSE, HideEffect);//关闭房间 } private void ShowEffect(System.Object data = null) { ExitBtn.gameObject.SetActive(true); } private void HideEffect(System.Object data = null) { ExitBtn.gameObject.SetActive(false); } private void OnDestroy() { ResetBtn.onClick.RemoveListener(ResetClickBtn); ExitBtn.onClick.RemoveListener(ExitClickBtn); if (OpenVufoiraBtn != null) OpenVufoiraBtn.onClick.RemoveListener(OpenVufoiraClick); if (CloseVufoiraBtn != null) { CloseVufoiraBtn.onClick.RemoveListener(CloseVufoiraClick); } MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_ENTER_COURSE, ShowEffect);//进入房间 MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_EXIT_COURSE, HideEffect);//关闭房间 } private void ResetClickBtn() { SvrPlugin.Instance.RecenterTracking(); } private void ExitClickBtn() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #elif UNITY_IPHONE || UNITY_ANDROID Application.Quit(); #endif } private void OpenVufoiraClick() { CloseVufoiraBtn.gameObject.SetActive(true); OpenVufoiraBtn.gameObject.SetActive(false); CDebug.Log("开启扫描识别的点击"); MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SEND_CHANGE_TRACK_IMAGE, true); } private void CloseVufoiraClick() { CloseVufoiraBtn.gameObject.SetActive(false); OpenVufoiraBtn.gameObject.SetActive(true); CDebug.Log("关闭扫描识别的点击"); MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SEND_CHANGE_TRACK_IMAGE, false); } }