예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <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);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
        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);
        }