void Update() { if (loading.Count > 0) { ArrayList keys = new ArrayList(loading.Keys); foreach (var k in keys) { string key = k as string; CGameUIAsset asset = loading[key] as CGameUIAsset; if (asset != null) { asset.Update(); } } } for (int i = 0; i < uis.Length; ++i) { if (uis[i] == null) { continue; } if (uis[i].asset != null) { uis[i].asset.Update(); } } }
public void Remove(CGameUI ui) { if (!ui || ui.disposed) { return; } if (ui.index < 0) { return; } uis[ui.index] = null; ui.Close(); names.Remove(ui.Name); index_pool.Free(ui.index); ui.index = -1; if (loading.ContainsKey(ui.Name)) { CGameUIAsset asset = loading[ui.Name] as CGameUIAsset; CClientCommon.DestroyImmediate(ref asset); loading.Remove(ui.Name); } ui.Dispose(); ui = null; }
public void Clear(bool reconnectToServer = false) { for (int i = 0; i < uis.Length; ++i) { if (uis[i] != null) { if (!uis[i].dontDestoryOnLoad) { Remove(uis[i]); } else { if (!reconnectToServer) { uis[i].OnLoadLevelBegin(); } } } } ArrayList keys = new ArrayList(loading.Keys); foreach (var k in keys) { string key = k as string; CGameUIAsset asset = loading[key]; if (asset != null && !asset.dontDestoryOnLoad) { CClientCommon.DestroyImmediate(ref asset); } loading.Remove(key); } }
public void SetAsset(CGameUIAsset asset) { this.asset = asset; if (this.asset != null) { this.asset.dontDestoryOnLoad = _dontDestoryOnLoad; } }
public void UIDispose() { for (int i = 0; i < uis.Length; ++i) { if (uis[i] != null) { Remove(uis[i]); } } names.Clear(); foreach (var e in loading.Values) { CGameUIAsset asset = e as CGameUIAsset; CClientCommon.DestroyImmediate(ref asset); } loading.Clear(); }
public void LoadUI(Type ui_type, object context = null, bool needwait = false) { if (ui_type == null || !ui_type.IsSubclassOf(typeof(CGameUI))) { return; } string ui_name = rg.Match(ui_type.Name).Value; CGameUI exists = Global.ui_mgr.Get(ui_name) as CGameUI; if (exists != null) { exists.context = context;//在界面还没有show前赋值所传的参数列表 if (!exists.IsShow()) { exists.Show(); } exists.LoadUICallback(); return; } // 防止重复加载 if (IsLoading(ui_name)) { return; } CGameUIAsset asset = CResourceFactory.CreateInstance <CGameUIAsset>(string.Format("res/ui/uiprefab/{0}.ui", ui_name).ToLower(), null); AddLoading(ui_name, asset); asset.RegisterCompleteCallback(delegate(CGameUIAsset e) { CGameUI ui = e.gameObject.AddComponent(ui_type) as CGameUI; ui.SetName(ui_name); ui.SetAsset(e); ui.context = context; Global.ui_mgr.Add(ui); ui.LoadUICallback(); RemoveLoading(ui_name); }); }
private void AddLoading(string name, CGameUIAsset asset) { loading.Add(name, asset); }