private void LoadScene(string sceneName, SceneLoadMode loadMode, object sceneData = null) { //string sceneName = typeof (T).ToString (); //GameObject uiObject; //string perfbName = "Scenes/" + sceneName; if (m_loadedScene.Contains(sceneName)) { return; } //m_currentSceneName = sceneName; sceneName = sceneName.ToLower(); m_loadedScene.Add(sceneName); //Debug.Log ("Loaded Perfab : " + perfbName); if (loadMode == SceneLoadMode.Single) { AssetsManager.Instance().LoadScene( sceneName, UnityEngine.SceneManagement.LoadSceneMode.Single); } else if (loadMode == SceneLoadMode.Additive) { AssetsManager.Instance().LoadScene( sceneName, UnityEngine.SceneManagement.LoadSceneMode.Additive); } //UnityEngine.SceneManagement.LoadSceneMode.Single return; }
IEnumerator AfterInitialize() { #if UNITY_EDITOR #else //After Assetmanager is loaded, loading other modole while (!AssetsManager.Instance().IsAssetBundleManagerLoaded) { yield return(null); } #endif AddGameObject <SceneManager> (); //AddGameObject<SoundService> (); AddGameObject <UIManager> (); //AddGameObject<PrefabManager> (); //EventManager.Instance.LogicStart (); // AddGameObject<CameraService>(); //AddGameObject<InputService> (); //AddGameObject<TimerService> (); //AddGameObject<Console> (); AddGameObject <Localization> (); //Add ECS system //AddEntitas (); //SceneManager.Instance ().AddSceneLoadedEvent (Handlecallback); SceneManager.Instance().LoadScene(SceneLookupEnum.World_UITestScene, SceneLoadMode.Additive); yield return(null); }
public void ShowBox <T>(Dictionary <string, object> varList = null) where T : UIBox { string name = typeof(T).ToString(); var panelTran = m_box.transform.Find(name); GameObject uiObject; if (panelTran == null) { string perfbName = "UI/Box/" + typeof(T).ToString(); //GameObject perfb = AssetsManager.LoadPrefab<GameObject> (perfbName); #if UNITY_EDITOR GameObject uiPrefab = AssetsManager.Instance().LoadPrefab <GameObject>(perfbName); if (uiPrefab == null) { Debug.Log("UIPanel Can`t Find Perfab"); } uiObject = GameObject.Instantiate(uiPrefab); uiObject.name = name; T t = uiObject.AddComponent <T>(); uiObject.transform.SetParent(m_box.transform); //t.PanelInit(); OpenUIBoxOpen <T>(uiObject); #else AssetsManager.Instance().LoadPrefab(perfbName, (AssetBundle obj) => { GameObject perfb; if (obj == null) { Debug.Log("UIPanel Can`t Find Perfab"); } perfb = obj.mainAsset as GameObject; uiObject = GameObject.Instantiate(perfb); uiObject.name = obj.name.Substring(0, obj.name.IndexOf('.')); T t = uiObject.AddComponent <T> (); uiObject.transform.SetParent(m_box.transform); t.PanelInit(); OpenUIBoxOpen <T> (uiObject); }); #endif //uiObject = GameObject.Instantiate (perfb); //uiObject.name = name; //T t = uiObject.AddComponent<T> (); //uiObject.transform.SetParent (m_box.transform); //t.PanelInit (); } else { uiObject = panelTran.gameObject; OpenUIBoxOpen <T>(uiObject); } //if (uiObject) { // T box = uiObject.GetComponent<T> (); // box.PanelOpen (); // if (varList != null) // box.m_userData = varList; // if (m_currentBox) // m_currentBox.gameObject.SetActive (false); // uiObject.SetActive (true); // m_currentBox = box; //} }
/// <summary> /// Shows the panel. /// /// 显示一个panel,panel是最为简单的UI元素,只是单纯显示在画面中, /// 所有的处理都交给Panel本身解决,建议在复杂频繁的UI切换中中不要使用panel /// 或者把一系列Panel置于一个父对象上统一管理开关 /// </summary> /// <returns>The panel.</returns> /// <param name="isFramework">这个UI是否为框架使用的。设为<c>true</c>是用于框架级的UI预设。通常都是false。</param> /// <param name="varList">Variable list.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public void ShowPanel <T>(bool isFramework = false, Callback callback = null, Dictionary <string, object> varList = null) where T : UIPanel { string panelName = typeof(T).ToString(); //Debug.Log (name); Transform panelTran = m_panel.transform.Find(panelName); GameObject uiObject; //T panel = null; if (panelTran == null) { string perfbName; #if UNITY_EDITOR if (!isFramework) { perfbName = string.Format("UI/Panel/{0}", typeof(T)); } else { perfbName = string.Format("Skylight/UI/Panel/{0}", typeof(T)); } GameObject uiPrefab = AssetsManager.Instance().LoadPrefab <GameObject>(perfbName); if (uiPrefab == null) { Debug.Log("UIPanel Can`t Find Perfab " + perfbName); } uiObject = GameObject.Instantiate(uiPrefab); uiObject.name = panelName; T t = uiObject.AddComponent <T>(); uiObject.transform.SetParent(m_panel.transform); //t.PanelInit(); OpenUIPanel <T>(uiObject); callback?.Invoke(); #else if (!isFramework) { perfbName = string.Format("UI/Panel/{0}.unity3d", typeof(T)); } else { perfbName = string.Format("Skylight/UI/Panel/{0}.unity3d", typeof(T)); } AssetsManager.Instance().LoadPrefab(perfbName, (AssetBundle obj) => { GameObject perfb; perfb = obj.LoadAsset <GameObject>(panelName); //perfb = obj.mainAsset as GameObject; if (perfb == null) { Debug.Log("UIPanel Can`t Find Perfab"); return; } uiObject = GameObject.Instantiate(perfb); uiObject.name = panelName; T t = uiObject.AddComponent <T>(); uiObject.transform.SetParent(m_panel.transform); t.PanelInit(); OpenUIPanel <T>(uiObject); callback?.Invoke(); }); #endif //if (perfb == null) { // Debug.Log ("UIPanel Can`t Find Perfab"); //} //uiObject = GameObject.Instantiate (perfb); //uiObject.name = name; //T t = uiObject.AddComponent<T> (); //uiObject.transform.SetParent (m_panel.transform); //t.PanelInit (); } else { uiObject = panelTran.gameObject; OpenUIPanel <T>(uiObject); callback?.Invoke(); } return; }