/// <summary> /// 创建一个UI,但是并不管理该UI的对象,需要得到它的模块自己管理,用于公共动态UI的创建 /// </summary> public T createUI <T>(string path, UIBase uiMount) where T : UIBase, new() { if (!_CommonUIList.ContainsKey(path)) { UTLog.Error("公共UI:" + path + "未做预加载!!!"); return(null); } GameObject showuiobj = Object.Instantiate(_CommonUIList[path]) as GameObject; T t = showuiobj.AddComponent <T>(); uiMount.CommonUIList.Add(t); showuiobj.name = t.name; t.mUIShowObj = showuiobj; t._OnLoadedShowUI(); t.OnAutoLoadedUIObj(); //ResourceManager.Load(path, _OnLoadedUI, BundleType.UI, t); return(t); }
//加载ui完成回调 private void _OnLoadedUIAddToRoot(Object obj, object ob) { if (obj != null) { UIBase uibase = (UIBase)ob; GameObject uishowobj = GameObject.Instantiate((GameObject)obj); uishowobj.name = uibase.uiTypeName + "(Show)"; UIBase ui = _mdicUIUnderRoot[uibase.uiTypeName]; GameObject logicUIObj = ui.gameObject; ui.mUIShowObj = uishowobj; uishowobj.transform.SetParent(logicUIObj.transform); ui._OnLoadedShowUI(); ui.OnAutoLoadedUIObj(); SetUIActive(ui, false); } else { UTLog.Error("值为空"); } }
/// <summary> /// 得到当前类型的UI对象 /// </summary> public T GetTargetUI <T>() where T : UIBase { UIBase ui = null; _mdicUIUnderRoot.TryGetValue(typeof(T).Name, out ui); if (ui == null) { UTLog.Error("不存在UI:" + typeof(T).Name); return(null); } if (!ui.bShowUILoaded) { UTLog.Error("UI未创建完成:" + typeof(T).Name); return(null); } return(ui as T); }