public int GetSort(XUIWindow window) { int index = -1; for (int i = 0; i < m_ltSort.Count; ++i) { var temp = m_ltSort[i]; if (temp == window) { index = i; break; } //层级越低排在越前面(越早绘制) if (window.layer < temp.layer) { index = i; break; } //层级相同,打开时间越小排在越前面(越早绘制) if (window.layer == temp.layer && window.openTick < temp.openTick) { index = i; break; } } if (index == -1) { index = m_ltSort.Count; } XDebug.Log(XUIConst.Tag, $"GetSort {window.name} {index}"); return(index); }
//设置canvas的排序和mask位置 void _UpdateSortAndMask() { int max = m_ltSort.Count; XUIWindow topMask = null; for (int i = 0; i < max; ++i) { var window = m_ltSort[i]; window.canvas.sortingOrder = i * XUIConst.LayerPaddingInner; if (window.mono.mask) { topMask = window; } } if (topMask == null) { uiRoot.HideMask(); m_maskWindow = null; return; } if (topMask == m_maskWindow) { return; } uiRoot.ShowMask(topMask.canvas.transform); m_maskWindow = topMask; Debug.Log($"mask is under {m_maskWindow.name}"); }
public void ShowWindow(string name, object param = null) { XDebug.Log(XUIConst.Tag, $"ShowWindow {name}"); XUIWindow window = null; if (m_dictWindows.ContainsKey(name)) { window = m_dictWindows[name]; } else { var paramBundle = new XUIParamBundle(); paramBundle.AssetLoader = AssetLoader; paramBundle.LocalizationLoader = LocalizationLoader; paramBundle.EventManager = EventManager; paramBundle.MsgManager = MsgManager; paramBundle.uiRoot = uiRoot; paramBundle.TextureManager = TextureManager; window = XObjectPool.Alloc <XUIWindow>(); window.Init(this, paramBundle, name, param); m_listWindows.Add(window); m_dictWindows.Add(name, window); } window.DstState = XUIWindow.EnumState.Show; window.openTick = Time.realtimeSinceStartup; }
public void HideWindow(string name) { XDebug.Log(XUIConst.Tag, $"HideWindow {name}"); if (!m_dictWindows.ContainsKey(name)) { return; } XUIWindow window = m_dictWindows[name]; window.DstState = XUIWindow.EnumState.Hide; }
//销毁窗口对象 void _DestroyWindow(string name) { if (!m_dictWindows.ContainsKey(name)) { return; } XUIWindow window = m_dictWindows[name]; window.Term(); m_listWindows.Remove(window); m_dictWindows.Remove(name); }
public void AddSort(XUIWindow window, int index) { if (index != -1) { m_ltSort.Insert(index, window); } else { m_ltSort.Add(window); } m_ltSortChanged = true; Debug.Log("addslot" + m_ltSort.Count); }
protected override bool _CheckMethod(XUIWindow obj) { return(obj.CurState == XUIWindow.EnumState.Remove); }
public void DelSort(XUIWindow window) { m_ltSort.Remove(window); m_ltSortChanged = true; Debug.Log("delslot" + m_ltSort.Count); }