private void _HideAll() { _panelsPreventAction.Clear(); foreach (var kv in _panelsOnCurrentScene) { foreach (var subKv in kv.Value) { GameObject p = subKv.Value; if (p && p.activeSelf) { CommonPanel c = p.GetComponent <CommonPanel>(); if (c != null) { try { c.OnBtnCloseClicked(); } catch (Exception e) { D.Log(e); } } } } } }
private void _Hide(string PanelName) { string path = System.IO.Path.Combine(PanelPath, PanelName + ".prefab"); var p = GetPanel(path); if (p != null && p.activeSelf) { MarkPanelWontPreventAction(path); CommonPanel c = p.GetComponent <CommonPanel>(); if (c != null) { try { c.OnBtnCloseClicked(); } catch (Exception e) { D.Log(e); } } } }
private void _Show <DataType>(string PanelName, DataType data) where DataType : class { string path = System.IO.Path.Combine(PanelPath, PanelName + ".prefab"); Type PanelType = Type.GetType(PanelName, false, true); if (PanelType != null) { Assert.IsTrue(PanelType.IsSubclassOf(typeof(CommonPanel))); } var p = GetPanel(path); if (p != null) { bool preventAction = true; CommonPanel c = null; if (PanelType != null) { c = (CommonPanel)p.GetComponent(PanelType); } if (c == null) { c = p.GetComponent <CommonPanel>(); } if (c != null) { try { c.SetClosedCallback(() => { MarkPanelWontPreventAction(path); }); if (data != null) { c.SetData((System.Object)data); } preventAction = c.PreventAction; } catch (Exception e) { D.Log(e); } } p.SetActive(true); // Bring Node To Front RectTransform trans = p.GetComponent <RectTransform>(); if (trans != null) { trans.SetAsLastSibling(); } if (preventAction) { MarkPanelPreventAction(path); } return; } // WaitView.Show(); InstantiatePrefab(path, (GameObject panel) => { Assert.IsNotNull(panel); var rt = panel.transform as RectTransform; if (rt != null) { SetPanel(path, rt.gameObject); bool preventAction = true; CommonPanel c = null; if (PanelType != null) { c = (CommonPanel)panel.GetComponent(PanelType); } if (c == null) { c = panel.GetComponent <CommonPanel>(); } if (c != null) { try { c.SetClosedCallback(() => { MarkPanelWontPreventAction(path); }); if (data != null) { c.SetData((System.Object)data); } preventAction = c.PreventAction; } catch (Exception e) { D.Log(e); } } rt.gameObject.SetActive(false); var canvas = UnityEngine.Object.FindObjectOfType <Canvas>(); rt.SetParent(canvas.transform, true); rt.SetAsLastSibling(); rt.gameObject.SetActive(true); if (preventAction) { MarkPanelPreventAction(path); } } }); }