| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- /* Home场景管理者 */
- public class HomeMgr : MonoBehaviour
- {
- public static HomeMgr ins;
- void Awake()
- {
- ins = this;
- PersistenHandler.Init();
- }
- void Start() {
- ResumeCacheViews();
- UserPlayer.ConnectServer();
- }
- void OnDestroy()
- {
- if (ins == this) ins = null;
- }
- #region 从主页到游戏场景,再回来时,恢复之前的页面
- static HashSet<MonoBehaviour> curCacheViews = new HashSet<MonoBehaviour>();
- public static void CacheView(MonoBehaviour view) {
- GameObject.DontDestroyOnLoad(view);
- curCacheViews.Add(view);
- }
- public static void RemoveCacheView(MonoBehaviour view) {
- curCacheViews.Remove(view);
- }
- public static void DestroyCacheViews() {
- foreach (var item in curCacheViews) {
- if (item && item.gameObject) {
- Destroy(item.gameObject);
- }
- }
- }
- public static void HideCacheViews() {
- foreach (var item in curCacheViews) item.gameObject.SetActive(false);
- }
- public void ResumeCacheViews() {
- foreach (var item in curCacheViews) item.gameObject.SetActive(true);
- }
- #endregion
- //登录认证的Mask
- public void ShowAuthLoginMask(bool visiable) {
- transform.Find("AuthLoginMask").gameObject.SetActive(visiable);
- }
- public void SetAuthLoginText(string text) {
- transform.Find("AuthLoginMask").GetComponentInChildren<Text>().text = text;
- }
- public bool IsAuthLoginMaskActive() {
- return transform.Find("AuthLoginMask").gameObject.activeSelf;
- }
- }
|