/// <summary> /// Changes the current panel to the specified panel id. /// </summary> public void ChangeCurrentPanel(string panelId) { UiPanelInterface panel; if (_uiPanelDataHolder.TryGetValue (panelId, out panel)) { UiPanelInterface prevPanel = _currentPanel; if (prevPanel != null) { prevPanel.Deactivate (); } _currentPanel = panel; _currentPanelId = panelId; _currentPanel.Activate (); // Trigger callback. { if (OnPanelChange != null) { PanelChangeContext context = new PanelChangeContext(); context.PreviousPanel = prevPanel; context.CurrentPanel = _currentPanel; OnPanelChange(context); } } } else { Debug.LogError ("Unable to activate a panel that is not registered: " + panelId); } }
/// <summary> /// Changes the current panel to the specified panel id. /// </summary> public void ChangeCurrentPanel(string panelId) { UiPanelInterface panel; if (_uiPanelDataHolder.TryGetValue(panelId, out panel)) { UiPanelInterface prevPanel = _currentPanel; if (prevPanel != null) { prevPanel.Deactivate(); } _currentPanel = panel; _currentPanelId = panelId; _currentPanel.Activate(); // Trigger callback. { if (OnPanelChange != null) { PanelChangeContext context = new PanelChangeContext(); context.PreviousPanel = prevPanel; context.CurrentPanel = _currentPanel; OnPanelChange(context); } } } else { Debug.LogError("Unable to activate a panel that is not registered: " + panelId); } }
private void RegisterPanel(string name, UiPanelInterface panel) { #if UNITY_EDITOR if (_uiPanelDataHolder.ContainsKey(name)) { Debug.LogWarning("Panel with name [" + name + "] already exists."); } #endif // UNITY_EDITOR _uiPanelDataHolder [name] = panel; // Initialize the panel. panel.Initialize(this); }
protected override void Awake() { base.Awake(); // Register all child panels. MonoBehaviour[] panels = this.gameObject.GetComponentsInChildren <MonoBehaviour> (true); for (int i = 0; i < panels.Length; i++) { UiPanelInterface panel = panels [i] as UiPanelInterface; if (panel != null) { RegisterPanel(panel.GetName(), panel); } } }
private void RegisterPanel(string name, UiPanelInterface panel) { #if UNITY_EDITOR if (_uiPanelDataHolder.ContainsKey(name)) { Debug.LogWarning("Panel with name [" + name + "] already exists."); } #endif // UNITY_EDITOR _uiPanelDataHolder [name] = panel; // Initialize the panel. panel.Initialize (this); }