| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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;
- }
- 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;
- }
- }
|