private void _onSceneUnload(Scene _scene) { if (_scene.buildIndex < 0) { return; } UIBase ui = null; for (int i = 0; i < m_loaded_ui.Count;) { ui = m_loaded_ui[i]; if (ui.IsShow() && ui.SceneChangeAutoHide && _handleUIHide(ui)) { continue; } if (ui.DestroyMode == UIDestroyMode.SceneChange) { ui.OnUnload(); m_loaded_ui.RemoveAt(i); DestroyImmediate(ui.gameObject, true); continue; } i++; } m_windows_name_stack.Clear(); m_dialog_name_list.Clear(); }
private void _resetLayerSortingOrder(UILayer _layer) { Int32 layer = (Int32)_layer; Int32 count = m_layers[layer].childCount; Transform tf = null; UIBase ui = null; Int32 active_count = 0; for (Int32 i = 0; i < count; i++) { tf = m_layers[layer].GetChild(i); ui = tf.GetComponent <UIBase>(); if (ui.IsShow()) { ui.Canvas.overrideSorting = true; Int32 new_order = layer * m_max_layer_sorting_order + active_count * 100; if (ui.Canvas.sortingOrder != new_order) { ui.Canvas.sortingOrder = new_order; ui.OnSortingOrderChange(new_order); } active_count++; } } }
public void ShowUI(string _name, params object[] _args) { UIBase ui_obj = _getLoadedUI(_name); if (ui_obj != null && ui_obj.IsShow()) { ui_obj.transform.SetAsLastSibling(); _resetLayerSortingOrder(ui_obj.Layer); ui_obj.PreShow(null, _args); return; } if (ui_obj == null) { _createUI(_name, _base => { if (_base.Type == UIType.Window) { StartCoroutine(_showWindow(_base, _args)); } else if (_base.Type == UIType.Dialog) { StartCoroutine(_showDialog(_base, _args)); } }); } else { if (ui_obj.Type == UIType.Window) { StartCoroutine(_showWindow(ui_obj, _args)); } else if (ui_obj.Type == UIType.Dialog) { StartCoroutine(_showDialog(ui_obj, _args)); } } }