public void ShowUI <T> (bool bPushHistory = true, Dictionary <string, object> varList = null) where T : UIDialog { if (mCurrentDialog != null) { mCurrentDialog.gameObject.SetActive(false); mCurrentDialog = null; } string name = typeof(T).ToString(); GameObject uiObject; if (!mAllUIs.TryGetValue(name, out uiObject)) { string perfbName = "UI/Dialog/" + typeof(T).ToString(); Debug.Log(perfbName); GameObject perfb = AssetsManager.LoadPrefabs <GameObject> (perfbName); uiObject = GameObject.Instantiate(perfb); uiObject.name = name; uiObject.AddComponent <T> (); uiObject.transform.SetParent(mDialog.transform); mAllUIs.Add(name, uiObject); } else { uiObject.SetActive(true); } if (uiObject) { T panel = uiObject.GetComponent <T> (); if (varList != null) { panel.mUserData = varList; } mCurrentDialog = panel; uiObject.SetActive(true); if (bPushHistory) { mDialogs.Enqueue(panel); } } }
public void ShowScene <T> (Dictionary <string, object> varList = null) where T : BaseScene { if (mCurrentScene != null) { mCurrentScene.gameObject.SetActive(false); Debug.Log("destroy"); mCurrentScene = null; } string name = typeof(T).ToString(); GameObject uiObject; if (!mAllScenes.TryGetValue(name, out uiObject)) { Debug.Log("Poruduce new scene"); string perfbName = "Scenes/" + typeof(T).ToString(); Debug.Log(perfbName); GameObject perfb = AssetsManager.LoadPrefabs <GameObject> (perfbName); uiObject = GameObject.Instantiate(perfb); uiObject.name = name; uiObject.AddComponent <T> (); uiObject.transform.SetParent(transform); mAllScenes.Add(name, uiObject); } else { uiObject.SetActive(true); } if (uiObject) { T scene = uiObject.GetComponent <T> (); if (varList != null) { scene.mUserData = varList; } mCurrentScene = scene; uiObject.SetActive(true); } }
public void ShowPanel <T> (Dictionary <string, object> varList = null) where T : UIPanel { string name = typeof(T).ToString(); Debug.Log(name); var panelTran = mPanel.transform.Find(name); GameObject uiObject; if (panelTran == null) { string perfbName = "UI/Panel/" + typeof(T).ToString(); GameObject perfb = AssetsManager.LoadPrefabs <GameObject> (perfbName); if (perfb == null) { Debug.Log("UIPanel Can`t Find Perfab"); } uiObject = GameObject.Instantiate(perfb); uiObject.name = name; uiObject.AddComponent <T> (); uiObject.transform.SetParent(mPanel.transform); } else { uiObject = panelTran.gameObject; } if (uiObject) { T panel = uiObject.GetComponent <T> (); if (varList != null) { panel.mUserData = varList; } uiObject.SetActive(true); } }
public void ShowBox <T> (Dictionary <string, object> varList = null) where T : UIBox { string name = typeof(T).ToString(); var panelTran = mBox.transform.Find(name); GameObject uiObject; if (panelTran == null) { string perfbName = "UI/Box/" + typeof(T).ToString(); GameObject perfb = AssetsManager.LoadPrefabs <GameObject> (perfbName); uiObject = GameObject.Instantiate(perfb); uiObject.name = name; uiObject.AddComponent <T> (); uiObject.transform.SetParent(mBox.transform); } else { uiObject = panelTran.gameObject; } if (uiObject) { T box = uiObject.GetComponent <T> (); if (varList != null) { box.mUserData = varList; } if (mCurrentBox) { mCurrentBox.gameObject.SetActive(false); } uiObject.SetActive(true); mCurrentBox = box; } }