/// <summary> /// Changes the current panel to the specified panel id. /// </summary> public void ChangeCurrentPanel(string panelId) { UiPanel panel; if (_uiPanelDataHolder.TryGetValue (panelId, out panel)) { { UiPanel prevPanel = _currentPanel; if (prevPanel != null) { PanelExitContext context = new PanelExitContext(); // Debug.Log("Exit: " + prevPanel.name); prevPanel.OnExit (context); } } { PanelEnterContext context = new PanelEnterContext(); _currentPanel = panel; _currentPanelId = panelId; // Debug.Log("Enter: " + _currentPanel.name); _currentPanel.OnEnter (context); } } else { Debug.LogError ("Unable to activate a panel that is not registered: " + panelId); } }
private void Start() { // Owner panel should have been added during Awake. // If owner is not set yet (this object was added dynamically during run-time), then // we need to find the owner manually. if (_ownerPanel == null) { _ownerPanel = Uzu.Util.FindInParents <UiPanel> (this.gameObject); if (_ownerPanel == null) { Debug.LogWarning ("UiWidget [" + this.name + "] does not belong to a panel."); } } }
protected void Awake() { // Register all child panels. MonoBehaviour[] panels = this.gameObject.GetComponentsInChildren <MonoBehaviour> (true); for (int i = 0; i < panels.Length; i++) { UiPanel panel = panels [i] as UiPanel; if (panel != null) { RegisterPanel(panel.gameObject.name, panel); } } }
private void RegisterPanel(string name, UiPanel 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. // Debug.Log("Init: " + panel.name); panel.Initialize (this); }
private void Start() { // Owner panel should have been added during Awake. // If owner is not set yet (this object was added dynamically during run-time), then // we need to find the owner manually. if (_ownerPanel == null) { _ownerPanel = Uzu.Util.FindInParents <UiPanel> (this.gameObject); if (_ownerPanel == null) { Debug.LogWarning("UiWidget [" + this.name + "] does not belong to a panel."); } } }
private void RegisterPanel(string name, UiPanel 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. // Debug.Log("Init: " + panel.name); panel.Initialize(this); }
/// <summary> /// Initialize this widget and set the connection to the owner panel. /// </summary> public void Initialize(UiPanel ownerPanel) { _ownerPanel = ownerPanel; }
/// <summary> /// Initialize this widget and set the connection to the owner panel. /// </summary> public void Initialize(UiPanel ownerPanel) { _ownerPanel = ownerPanel; }