protected void CloseAtIndex(GameUI gameui, int index, bool force = false, AbstractParams p = null) { if (!removeList.Contains(gameui)) { //check children GameUI[] childrenUI = gameui.GetComponentsInChildren <GameUI>(); for (int i = 0; i < childrenUI.Length; ++i) { if (childrenUI[i] != gameui) { for (int j = 0; j < uicontainer.Count; ++j) { if (uicontainer[j] == childrenUI[i]) { CloseAtIndex(uicontainer[j], j, force); } } } } ScriptCommand cmd = ScriptCommand.Create((int)FrameWorkCmdDefine.UICallExit); if (p != null) { cmd.CallParams = p; } cmd.target = ScriptTarget.Sharp; cmd.CallParams.InsertObject(0, gameui); cmd.Excute(); if (p != null) { p.Release(); } CacheCommand.CanCelAllBy(gameui); if (force) { gameui.DestorySelf(); } else { DestroyUI(gameui); } removeList.Add(gameui); } }
public virtual void Clear(bool all) { for (int i = this.uicontainer.Count - 1; i >= 0; i--) { GameUI ui = this.uicontainer[i]; if (ui != null) { if (!all) { CacheCommand.CanCelAllBy(ui); } else { this.CloseAtIndex(ui, i, all); } } } this.removeList.Clear(); this.uicontainer.Clear(); }
/// <summary> /// 脱离ugui 的uibehaviour 和graphic 类的canvas rebuild ,直接等待下一帧,确保canvas的初始化完成 /// </summary> void NextFrame(FrameCommand cmd) { if (this == null) { CacheCommand.CanCelAllBy(this); return; } this.uidepth = this.rectTransform.GetSiblingIndex(); if (!HasEnter) { if (this.ParentLayout != null) { this.gameObject.layer = this.ParentLayout.UILayer; } GameUI[] uiarray = this.GetComponentsInChildren <GameUI>(true); for (int i = 0; i < uiarray.Length; ++i) { GameUI ui = uiarray[i]; if (ui != null && ui.ParentLayout == null) { ui.ParentLayout = this.ParentLayout; } } if (LuaMode) { #if TOLUA if (table != null) { if (this.enterFunc == null) { this.enterFunc = table.GetLuaFunction("OnEnter"); } if (this.enterFunc != null) { this.enterFunc.BeginPCall(); this.enterFunc.Push(table); this.enterFunc.Push(enterParams); this.enterFunc.PCall(); this.enterFunc.EndPCall(); } else { this.OnEnter(enterParams); } } else { #if UNITY_EDITOR LogMgr.LogErrorFormat("找不到对应的{0} 的luatable path is :{1}", this, this.respath); #endif } #endif //if (enterParams != null) // enterParams.Release(); } else { this.OnEnter(enterParams); } enterParams = null; enterBefore = true; } }