HomeMgr.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class HomeMgr : MonoBehaviour
  5. {
  6. public static HomeMgr ins;
  7. void Awake()
  8. {
  9. ins = this;
  10. }
  11. void Start() {
  12. ResumeCacheViews();
  13. UserPlayer.ConnectServer();
  14. }
  15. void OnDestroy()
  16. {
  17. if (ins == this) ins = null;
  18. }
  19. #region 从主页到游戏场景,再回来时,恢复之前的页面
  20. static HashSet<MonoBehaviour> curCacheViews = new HashSet<MonoBehaviour>();
  21. public static void CacheView(MonoBehaviour view) {
  22. GameObject.DontDestroyOnLoad(view);
  23. curCacheViews.Add(view);
  24. }
  25. public static void RemoveCacheView(MonoBehaviour view) {
  26. curCacheViews.Remove(view);
  27. }
  28. public static void HideCacheViews() {
  29. foreach (var item in curCacheViews) item.gameObject.SetActive(false);
  30. }
  31. public void ResumeCacheViews() {
  32. foreach (var item in curCacheViews) item.gameObject.SetActive(true);
  33. }
  34. #endregion
  35. //登录认证的Mask
  36. public void ShowAuthLoginMask(bool visiable) {
  37. transform.Find("AuthLoginMask").gameObject.SetActive(visiable);
  38. }
  39. }