コード例 #1
0
ファイル: UiPanelMgr.cs プロジェクト: RCQuest/uzuutil
        /// <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
ファイル: UiPanelMgr.cs プロジェクト: rcabot/uzuutil
        /// <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
ファイル: UiPanelMgr.cs プロジェクト: rcabot/uzuutil
        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
ファイル: UiPanelMgr.cs プロジェクト: rcabot/uzuutil
        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
ファイル: UiPanelMgr.cs プロジェクト: RCQuest/uzuutil
        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);
        }