public static void LoadUi(UiInfo uiInfo, string resource, Type typeUi, Action <UiInstance> notify) { ResourceMgr.Load(resource, obj => { ResourceMgr.InstantiateX(obj, uiObject => { uiObject.SetActiveSafe(true); var script = GameObjectTools.AddComponent(uiObject, typeUi); UiInstance ui = script as UiInstance; if (ui) { ui.UiInfo = uiInfo; ui.OnLoadFinish(); notify(ui); } else { Debug.LogError(string.Format("Load UI fail ui == null resource{0}", resource)); } }); }); }
public static UiInstance ShowImmediately(string resource, Type typeUi) { var obj = ResourceMgr.LoadImmediately(resource); var uiObject = ResourceMgr.Instantiate(obj); if (uiObject) { uiObject.SetActiveSafe(true); var script = GameObjectTools.AddComponent(uiObject, typeUi); UiInstance ui = script as UiInstance; if (ui) { ui.OnLoadFinish(); return(ui); } Debug.LogError(string.Format("Load UI fail ui == null resource{0}", resource)); } else { Debug.LogError(string.Format("Load UI fail gameObject == null resource{0}", resource)); } return(null); }