public void RegisterWindow(int id, string path, WindowLayer layer, Type type) { if (m_WindowIndexStore.ContainsKey(id)) { return; } WindowIndexStruct element = new WindowIndexStruct(id, path, layer, type); m_WindowIndexStore.Add(id, element); }
public void OpenWindow(int windowId, object param = null) { if (m_WindowStore.ContainsKey(windowId)) { WindowBase currentWindow = m_WindowStore[windowId]; WindowIndexStruct currentWindowIndexStruct = m_WindowIndexStore[windowId]; if (currentWindow.IsOpen()) { return; } currentWindow.m_ObjectRoot.SetActive(true); // reset deepth ,do it befor add to actived window queue currentWindow.ResetDeepth(GetCurrentWindowDeepth(currentWindowIndexStruct.m_Layer)); //reset current layer deepth m_LayerIndexStore[currentWindowIndexStruct.m_Layer].m_iCurrent = currentWindow.GetMaxDeepthValue(); //add to actived window queue AddToActivedWindowQueue(currentWindowIndexStruct.m_Layer, currentWindow); // on open currentWindow.OnOpen(param); } else { WindowIndexStruct currentWindowIndexStruct = m_WindowIndexStore[windowId]; // load prefab WindowIndexStruct element = null; m_WindowIndexStore.TryGetValue(windowId, out element); if (null == element) { Debuger.LogError("can't load window : " + windowId.ToString()); } else { if (element.m_bIsBuildInWindow) { GameObject root = GameObject.Instantiate(ResourceManager.Instance.LoadBuildInResource <GameObject>(element.m_strPath, AssetType.UI)); WindowBase res = Activator.CreateInstance(currentWindowIndexStruct.m_Type) as WindowBase; ComponentTool.Attach(m_LayerIndexStore[currentWindowIndexStruct.m_Layer].m_Root.transform, root.transform); // initialize (include set position,set root ,set deepth ...) res.Initialize(windowId, root); // set deepth ,do it befor add to actived window queue res.ResetDeepth(GetCurrentWindowDeepth(currentWindowIndexStruct.m_Layer)); //reset current layer deepth m_LayerIndexStore[currentWindowIndexStruct.m_Layer].m_iCurrent = res.GetMaxDeepthValue(); //add to actived window queue AddToActivedWindowQueue(currentWindowIndexStruct.m_Layer, res); // save to window store m_WindowStore.Add(windowId, res); // on init res.OnInit(); // on open res.OnOpen(param); } else { ResourceManager.Instance.LoadBuildInAssetsAsync(element.m_strPath, AssetType.UI, (origin) => { GameObject root = GameObject.Instantiate(origin) as GameObject; WindowBase res = Activator.CreateInstance(currentWindowIndexStruct.m_Type) as WindowBase; ComponentTool.Attach(m_LayerIndexStore[currentWindowIndexStruct.m_Layer].m_Root.transform, root.transform); // initialize (include set position,set root ,set deepth ...) res.Initialize(windowId, root); // on init res.OnInit(); // set deepth ,do it befor add to actived window queue res.ResetDeepth(GetCurrentWindowDeepth(currentWindowIndexStruct.m_Layer)); //reset current layer deepth m_LayerIndexStore[currentWindowIndexStruct.m_Layer].m_iCurrent = res.GetMaxDeepthValue(); // on open res.OnOpen(param); //add to actived window queue AddToActivedWindowQueue(currentWindowIndexStruct.m_Layer, res); // save to window store m_WindowStore.Add(windowId, res); }); } } } }