public static Panel OpenPanel(string panelName) { PanelManager inst = Instance; if (inst == null) { return(null); } PanelAsset asset = inst.GetAsset(panelName); if (asset == null || !asset.IsUsable) { return(null); } else if (asset.Mode == EPanelMode.Dialog) { return(inst.OpenPanelAsDialog(asset, PanelIntentData.NONE)); } else if (asset.Mode == EPanelMode.Status || asset.Mode == EPanelMode.TopStatus) { return(inst.OpenPanelAsStatus(asset, PanelIntentData.NONE)); } else if (asset.Mode == EPanelMode.Normal) { return(inst.OpenPanelAsNormal(asset, PanelIntentData.NONE)); } else { return(null); } }
public static Panel OpenPanel(string panelName, IPanelMessager request = null) { PanelManager inst = Instance; if (inst == null) { return(null); } PanelAsset asset = inst.GetAsset(panelName); if (asset == null || !asset.IsUsable) { return(null); } else if (asset.Mode == EPanelMode.Dialog) { return(inst.OpenPanelAsDialog(asset, request)); } else if (asset.Mode == EPanelMode.Status) { return(inst.OpenPanelAsStatus(asset)); } else if (asset.Mode == EPanelMode.Normal) { return(inst.OpenPanelAsNormal(asset, request)); } else { return(null); } }
private void Start() { if (PanelManager.Instance != null) { mDefaultOpen = new LinkedList <int>(); mAssets = new PanelAsset[m_Panels.Length]; for (int i = 0; i < m_Panels.Length; i++) { if (m_Panels[i] == null) { continue; } bool act = m_Panels[i].gameObject.activeSelf; PanelAsset asset = new PanelAsset(m_Panels[i]); PanelManager.Instance.AddPanelAsset(asset); mAssets[i] = asset; if (act) { mDefaultOpen.AddLast(asset.Id); } } if (mDefaultOpen.Count > 0) { mCheckTime = 1; } } if (mAssets != null) { CheckOpen(2); } }
private void Awake() { if (Instance == null) { Instance = this; Panel[] panels = GetComponentsInChildren <Panel>(); int len = panels == null ? 0 : panels.Length; for (int i = 0; i < len; i++) { PanelAsset asset = new PanelAsset(panels[i]); if (asset.IsUsable) { mAssets.Add(asset); } } if (m_EventMask != null) { m_EventMask.Reset(); } if (m_DontDestroyOnLoad) { DontDestroyOnLoad(gameObject); } } else { gameObject.SetActive(false); name = name + "-unused"; } }
public static Panel OpenPanel <T>(int id, T request) { PanelManager inst = Instance; if (inst == null) { return(null); } PanelAsset asset = inst.GetAsset(id); if (asset == null || !asset.IsUsable) { return(null); } else if (asset.Mode == EPanelMode.Dialog) { return(inst.OpenPanelAsDialog(asset, request)); } else if (asset.Mode == EPanelMode.Status || asset.Mode == EPanelMode.TopStatus) { return(inst.OpenPanelAsStatus(asset, request)); } else if (asset.Mode == EPanelMode.Normal) { return(inst.OpenPanelAsNormal(asset, request)); } else { return(null); } }
Panel OpenPanelAsNormal <T>(PanelAsset asset, T request) { if (mDialogs.Count > 0) { return(null); } return(OpenPanelFor <T>(mPanels, m_NormalSortingLayer, asset, request, true)); }
Panel OpenPanelAsNormal(PanelAsset asset, IPanelMessager request) { if (mDialogs.Count > 0) { return(null); } return(OpenPanelFor(mPanels, m_NormalSortingLayer, asset, request, true)); }
public void RemoveAsset(PanelAsset asset) { if (asset == null) { return; } mAssets.Remove(asset); asset.Release(); }
PanelAsset GetAsset(string assetName) { for (int i = 0; i < mAssets.Count; i++) { PanelAsset asset = mAssets[i]; if (asset.Name == assetName) { return(asset); } } return(null); }
public void AddPanelAsset(PanelAsset asset) { if (asset == null) { return; } if (GetAsset(asset.Id) != null) { return; } mAssets.Add(asset); }
PanelAsset GetAsset(int panelId) { for (int i = 0; i < mAssets.Count; i++) { PanelAsset asset = mAssets[i]; if (asset.Id == panelId) { return(asset); } } return(null); }
public static void ReleasePanels() { PanelManager inst = Instance; if (inst == null) { return; } for (int i = 0; i < inst.mAssets.Count; i++) { PanelAsset asset = inst.mAssets[i]; asset.Release(); } }
public void RemoveAsset(PanelAsset asset) { if (asset == null || !mAssets.Contains(asset)) { return; } ClearPanelForAsset(asset, mClosing); ClearPanelForAsset(asset, mDialogs); ClearPanelForAsset(asset, mStatus); ClearPanelForAsset(asset, mPanels); mAssets.Remove(asset); asset.Release(); mFindFocusWindow = true; }
public void AddPanelAsset(PanelAsset asset) { if (asset == null) { return; } if (GetAsset(asset.Id) != null) { #if UNITY_EDITOR Debug.LogErrorFormat("Add Panel Asset(id:{0}, name:{1}) is exists.", asset.Id, asset.Name); #endif return; } mAssets.Add(asset); }
protected override void Awake() { base.Awake(); Panel[] panels = GetComponentsInChildren <Panel>(); int len = panels == null ? 0 : panels.Length; for (int i = 0; i < len; i++) { PanelAsset asset = new PanelAsset(panels[i]); if (asset.IsUsable) { mAssets.Add(asset); } } UpdateMask(); }
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); } } }
Panel OpenPanelAsStatus <T>(PanelAsset asset, T request) { return(OpenPanelFor <T>(mStatus, asset.Mode == EPanelMode.Status ? m_StatusSortingLayer : m_TopStatusSortingLayer, asset, request, false)); }
// 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); }
Panel OpenPanelAsDialog <T>(PanelAsset asset, T request) { return(OpenPanelFor <T>(mDialogs, m_DialogSortingLayer, asset, request, true)); }
Panel OpenPanelAsDialog(PanelAsset asset, IPanelMessager request) { return(OpenPanelFor(mDialogs, m_DialogSortingLayer, asset, request, true)); }
Panel OpenPanelAsStatus(PanelAsset asset) { return(OpenPanelFor(mStatus, m_StatusSortingLayer, asset, null, false)); }
// 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); }