HomeMgr.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 DestroyCacheViews() {
  29. foreach (var item in curCacheViews) {
  30. if (item && item.gameObject) {
  31. Destroy(item.gameObject);
  32. }
  33. }
  34. }
  35. public static void HideCacheViews() {
  36. foreach (var item in curCacheViews) item.gameObject.SetActive(false);
  37. }
  38. public void ResumeCacheViews() {
  39. foreach (var item in curCacheViews) item.gameObject.SetActive(true);
  40. }
  41. #endregion
  42. //登录认证的Mask
  43. public void ShowAuthLoginMask(bool visiable) {
  44. transform.Find("AuthLoginMask").gameObject.SetActive(visiable);
  45. }
  46. }