void ClearPanelForAsset(PanelAsset asset, List <PanelStub> panels) { for (int i = panels.Count - 1; i >= 0; i--) { PanelStub stub = panels[i]; if (stub.Asset == asset) { if (mFocusStub == stub) { stub.HasFocus = false; mFocusStub = null; mFindFocusWindow = true; } stub.Instance.OnPanelLostAsset(); asset.UnuseAsset(stub.Instance); panels.RemoveAt(i); } } }
// asset must be usable. Panel OpenPanelFor(List <PanelStub> list, int sortLayer, PanelAsset asset, IPanelMessager request, bool useFocus) { Panel panel = asset.InstantiateAsset(); if (panel == null || panel.IsClosing()) { return(null); } bool open; if (request != null) { open = panel.OnPanelOpenForResult(request); } else { open = panel.OnPanelOpen(); } if (!open) { asset.UnuseAsset(panel); return(null); } int close = GetPanelIndex(mClosing, panel); if (close != -1) { mClosing.RemoveAt(close); } panel.transform.SetParent(transform, false); int old = GetPanelIndex(list, panel); if (old != -1) { list.RemoveAt(old); } PanelStub stub = new PanelStub(); stub.Asset = asset; stub.Instance = panel; list.Add(stub); PanelStub prev = GetRecentPanel(list, 1); Canvas prevcan = prev == null ? null : prev.Instance.GetCanvas(); Canvas can = panel.GetCanvas(); can.renderMode = RenderMode.ScreenSpaceCamera; can.worldCamera = m_UICamera; can.sortingLayerID = sortLayer; can.sortingOrder = prevcan == null ? 1 : prevcan.sortingOrder + 2; if (useFocus) { if (mFocusStub != null) { mFocusStub.HasFocus = false; } mFocusStub = stub; mFocusStub.HasFocus = true; } if (asset.IsUseMask) { UpdateMask(); } return(panel); }
// asset must be usable. Panel OpenPanelFor <T>(List <PanelStub> list, int sortLayer, PanelAsset asset, T request, bool useFocus) { Panel panel = asset.InstantiateAsset(); if (panel == null || panel.IsClosing()) { return(null); } bool open; bool handint = false; if (!PanelIntentData.NONE.Equals(request)) { if (panel is IPanelIntent <T> ) { handint = true; open = panel.OpenPanel(); } else { open = false; } } else { open = panel.OpenPanel(); } if (!open) { asset.UnuseAsset(panel); return(null); } else if (handint) { ((IPanelIntent <T>)panel).HandleIntent(request); } panel.OnPanelOpened(); OnPanelOpened(panel); int close = GetPanelIndex(mClosing, panel); if (close != -1) { mClosing.RemoveAt(close); } //panel.transform.SetParent(transform, false); WaittingForOpenPanel = false; int old = GetPanelIndex(list, panel); if (old != -1) { list.RemoveAt(old); } PanelStub stub = new PanelStub(this); stub.Asset = asset; stub.Instance = panel; list.Add(stub); PanelStub prev = GetRecentPanel(list, 1); Canvas prevcan = prev == null ? null : prev.Instance.GetCanvas(); Canvas can = panel.GetCanvas(); SetupCanvas(can); can.sortingLayerID = sortLayer; if (asset.Mode != EPanelMode.Status && asset.Mode != EPanelMode.TopStatus) { can.sortingOrder = prevcan == null?GetSortOrder(asset.Mode) : prevcan.sortingOrder + 2; } if (useFocus) { if (mFocusStub != null) { mFocusStub.HasFocus = false; mFocusStub = null; } mFindFocusWindow = true; } if (asset.IsUseMask) { UpdateMask(); } return(panel); }