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, officeInt = 3, RoomInt = 4, publicInt = 5, } public enum SceneType { GameStartLogo = 10001, ShowLogin = 20001, ShowOffice = 30001, CreateRoom = 30101, JoinRoom = 30102, UserSystem = 30103, RemoteSystem = 30104, OfficeWindow =30105, ShowRoom = 40001, RoomMain = 40101, RoomOtherUser = 40102, RoomInfo = 40103, RoomFile = 40104, PopPublic = 50001, PopPeerView = 50101, PopUpInfo = 50101, PopCall = 50102, } private static ScenesManager instance; public static ScenesManager Instance { get { if (instance == null) { instance = new ScenesManager(); } return instance; } } public List windows = new List(); public Dictionary> dlglist = new Dictionary>(); public void initWindow(GameObject window) { SceneInfo sceneInfo = window.AddComponent(); 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); // window.SetActive(false); } else { if(dlglist.ContainsKey(codeint)) { List dlg = dlglist[codeint]; dlg.Add(sceneInfo); dlglist[codeint]=dlg; } else { List dlg = new List(); 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(); 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(); if (ppc) _popPublic= ppc; } } return _popPublic; } } public void initRoom() { for (int i = 0; i < dlglist[mType.RoomInt.GetHashCode()].Count; i++) { MonoBehaviour alist = dlglist[mType.RoomInt.GetHashCode()][i].GetComponent(); Type t = Type.GetType(alist.name); System.Reflection.MethodInfo md = t.GetMethod("initShow"); if (md != null) { md.Invoke(alist, null); } } } public void showOffice(SceneType stype) { for (int i = 0; i < dlglist[mType.officeInt.GetHashCode()].Count; i++) { if(stype == dlglist[mType.officeInt.GetHashCode()][i]._sceneType) { dlglist[mType.officeInt.GetHashCode()][i].gameObject.SetActive(true); MonoBehaviour alist = dlglist[mType.officeInt.GetHashCode()][i].GetComponent(); Type t = Type.GetType(alist.name); System.Reflection.MethodInfo md = t.GetMethod("initShow"); if (md != null) { md.Invoke(alist, null); } } else { dlglist[mType.officeInt.GetHashCode()][i].gameObject.SetActive(false); } } } public void showPop() { popPublic.gameObject.SetActive(true); } }