public virtual CDefaultScene ShowScene(string sceneName, bool savePath = true) { if (string.IsNullOrEmpty(sceneName)) { return(null); } if (this.m_SceneMaps.ContainsKey(sceneName) == false) { return(null); } // ROAD MAP if (savePath) { this.AddRoadMap(sceneName); } // ROOT OBJECT this.m_RootObject = this.m_SceneMaps[sceneName]; // CURRENT SCENE if (this.m_CurrentScene != null && this.m_CurrentScene.sceneObjectName == sceneName) { this.m_CurrentScene.SetActive(true); this.m_CurrentScene.GameObject.transform.SetParent(this.m_TopCanvas.transform); return(this.m_CurrentScene); } // ACTIVE && AWAKE foreach (var item in this.m_SceneMaps) { if (this.m_CurrentScene == null && item.Key == sceneName) { item.Value.SetActive(true); item.Value.OnStartObject(); item.Value.GameObject.transform.SetParent(this.m_TopCanvas.transform); // item.Value.GameObject.transform.SetAsLastSibling(); item.Value.SetObjectSceneAnimator("IsShow", true); this.m_CurrentScene = item.Value; } else { this.CloseScene(item.Key); } } // RETURN return(this.m_CurrentScene); }
public virtual CDefaultScene CloseScene(string sceneName) { if (this.m_SceneMaps.ContainsKey(sceneName)) { if (this.m_CurrentScene != null && this.m_CurrentScene.sceneObjectName == sceneName) { this.m_CurrentScene = null; } if (this.m_SceneMaps[sceneName].GameObject.activeInHierarchy) { this.m_SceneMaps[sceneName].OnDestroyObject(); this.m_SceneMaps[sceneName].GameObject.transform.SetParent(this.m_MainCanvas.transform); this.m_SceneMaps[sceneName].SetObjectSceneAnimatorAsync(CGameSetting.ANIM_OBJECT, "IsShow", false, (go) => { go.SetActive(false); }); return(this.m_SceneMaps[sceneName]); } } return(null); }