using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class BackController : MonoBehaviour { public GameObject BackBtns; public Button ToPrevBtn; public Button ToMenuBtn; public Button ToLoginBtn; public Action ToPrevAction; public Action ToMenuAction; public Action ToLoginAction; public Toggle MyToggle; void Awake() { MyToggle = GetComponentInChildren(); MyToggle.onValueChanged.AddListener(BackToggleClick); ToPrevBtn.onClick.AddListener(ToPrevBtnClick); ToMenuBtn.onClick.AddListener(ToMenuBtnClick); ToLoginBtn.onClick.AddListener(ToLoginBtnClick); } private void ToLoginBtnClick() { if (ToLoginAction != null) ToLoginAction.Invoke(); BackBtns.gameObject.SetActive(false); MyToggle.isOn = false; } private void ToMenuBtnClick() { if (ToMenuAction != null) ToMenuAction.Invoke(); BackBtns.gameObject.SetActive(false); MyToggle.isOn = false; } private void ToPrevBtnClick() { if (ToPrevAction != null) ToPrevAction.Invoke(); BackBtns.gameObject.SetActive(false); MyToggle.isOn = false; } private void BackToggleClick(bool ok) { if (CurrentUserInfo.room!=null&&CurrentUserInfo.room.IsDrillStart) { LoadPromptWin.Instance.LoadTextPromptWindow("房间已锁定,不能进行返回操作!",1f); BackBtns.gameObject.SetActive(false); return; } BackBtns.gameObject.SetActive(ok); } }