123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using SC.XR.Unity;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ScenesManager
- {
- public enum mType
- {
- LogoInt = 1,
- LoginInt = 2,
- ShowChoose = 3,
- ShowXunJian = 4,
- ShowRTC = 5,
- ShowZhiDao = 6,
- publicInt = 7,
- DeviceInfo = 8,
- Navigationing = 9,
- }
- public enum SceneType
- {
- GameStartLogo = 10001,
- ShowLogin = 20001,
- ShowChoose = 30001,
- ShowXunJian = 40001,
- ShowXJ = 41001,
- ShowDH = 41002,
- ShowRTC = 50001,
- ShowRTCHistory = 51002,
-
- ShowDevice = 60001,
- DeviceDetails = 61002,
- Navigationing = 80001,
- PopPublic = 70001,
- }
- private static ScenesManager instance;
- public static ScenesManager Instance
- {
- get
- {
- if (instance == null)
- {
- instance = new ScenesManager();
- }
- return instance;
- }
- }
- public List<SceneInfo> windows = new List<SceneInfo>();
- public Dictionary<int, List<SceneInfo>> dlglist = new Dictionary<int, List<SceneInfo>>();
- public void initWindow(GameObject window)
- {
- SceneInfo sceneInfo = window.AddComponent<SceneInfo>();
- SceneType stp = (SceneType)System.Enum.Parse(typeof(SceneType), window.name.Split('(')[0]);
- sceneInfo.setType(stp);
- int codeint = stp.GetHashCode() / 10000;
- if (stp.GetHashCode() - (codeint * 10000) == 1)
- {
- windows.Add(sceneInfo);
-
- }
- else
- {
- if (dlglist.ContainsKey(codeint))
- {
- List<SceneInfo> dlg = dlglist[codeint];
- dlg.Add(sceneInfo);
- dlglist[codeint] = dlg;
- }
- else
- {
- List<SceneInfo> dlg = new List<SceneInfo>();
- dlg.Add(sceneInfo);
- dlglist.Add(codeint, dlg);
- }
- }
- }
- public void showWindow(SceneType sceneType)
- {
- for (int i = 0; i < windows.Count; i++)
- {
- int codeint = windows[i]._sceneType.GetHashCode() / 10000;
- if (windows[i]._sceneType == sceneType || codeint == mType.publicInt.GetHashCode())
- {
- windows[i].gameObject.SetActive(true);
- MonoBehaviour alist = windows[i].GetComponent<MonoBehaviour>();
- Type t = Type.GetType(alist.name);
- System.Reflection.MethodInfo md = t.GetMethod("initShow");
- if (md != null)
- {
- md.Invoke(alist, null);
- }
- }
- else
- {
- windows[i].gameObject.SetActive(false);
- }
- }
- }
- public void initPopUp()
- {
- for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
- {
- dlglist[mType.publicInt.GetHashCode()][i].gameObject.SetActive(false);
- }
- }
- private PopPublic _popPublic;
- public PopPublic popPublic
- {
- get
- {
- if (!_popPublic)
- {
- for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
- {
- PopPublic ppc = dlglist[mType.publicInt.GetHashCode()][i].GetComponent<PopPublic>();
- if (ppc)
- _popPublic = ppc;
- }
- }
- return _popPublic;
- }
- }
- public void showPop()
- {
- popPublic.gameObject.SetActive(true);
- }
- }
|