Ejemplo n.º 1
0
        public void AddTab(SRTab tab, bool visibleInSidebar = true)
        {
            tab.CachedTransform.SetParent(TabContentsContainer, false);
            tab.CachedGameObject.SetActive(false);

            if (visibleInSidebar)
            {
                // Create a tab button for this tab
                var button = SRInstantiate.Instantiate(TabButtonPrefab);
                button.CachedTransform.SetParent(TabButtonContainer, false);
                button.TitleText.text = tab.Title.ToUpper();

                if (tab.IconExtraContent != null)
                {
                    var extraContent = SRInstantiate.Instantiate(tab.IconExtraContent);
                    extraContent.SetParent(button.ExtraContentContainer, false);
                }

                button.IconStyleComponent.StyleKey = tab.IconStyleKey;
                button.IsActive = false;

                button.Button.onClick.AddListener(() => MakeActive(tab));

                tab.TabButton = button;
            }

            _tabs.Add(tab);
            SortTabs();

            if (_tabs.Count == 1)
            {
                ActiveTab = tab;
            }
        }
        public void AddTab(SRTab tab, bool visibleInSidebar = true)
        {
            tab.CachedTransform.SetParent(TabContentsContainer, false);
            tab.CachedGameObject.SetActive(false);

            if (visibleInSidebar)
            {
                // Create a tab button for this tab
                var button = SRInstantiate.Instantiate(TabButtonPrefab);
                button.CachedTransform.SetParent(TabButtonContainer, false);
                button.TitleText.text = tab.Title.ToUpper();

                if (tab.IconExtraContent != null)
                {
                    var extraContent = SRInstantiate.Instantiate(tab.IconExtraContent);
                    extraContent.SetParent(button.ExtraContentContainer, false);
                }

                button.IconStyleComponent.StyleKey = tab.IconStyleKey;
                button.IsActive = false;

                button.Button.onClick.AddListener(() => MakeActive(tab));

                tab.TabButton = button;
            }

            _tabs.Add(tab);
            SortTabs();

            if (_tabs.Count == 1)
            {
                ActiveTab = tab;
            }
        }
        protected override void Start()
        {
            base.Start();

            _hasStarted = true;

            // Loads all available tabs from resources
            var tabs = Resources.LoadAll<SRTab>("SRDebugger/UI/Prefabs/Tabs");
            var defaultTabs = Enum.GetNames(typeof (DefaultTabs));

            foreach (var srTab in tabs)
            {
                var enabler = srTab.GetComponent(typeof (IEnableTab)) as IEnableTab;

                if (enabler != null && !enabler.IsEnabled)
                {
                    continue;
                }

                if (defaultTabs.Contains(srTab.Key))
                {
                    var tabValue = Enum.Parse(typeof (DefaultTabs), srTab.Key);

                    if (Enum.IsDefined(typeof (DefaultTabs), tabValue) &&
                        Settings.Instance.DisabledTabs.Contains((DefaultTabs) tabValue))
                    {
                        continue;
                    }
                }

                TabController.AddTab(SRInstantiate.Instantiate(srTab));
            }

            // Add about tab (has no button, accessed via "Stompy" logo
            if (AboutTab != null)
            {
                _aboutTabInstance = SRInstantiate.Instantiate(AboutTab);
                TabController.AddTab(_aboutTabInstance, false);
            }

            // Open active tab (set before panel loaded), or default tab from settings
            var defaultTab = _activeTab ?? Settings.Instance.DefaultTab;

            if (!OpenTab(defaultTab))
            {
                TabController.ActiveTab = TabController.Tabs.FirstOrDefault();
            }
        }
Ejemplo n.º 4
0
        private void MakeActive(SRTab tab)
        {
            if (!_tabs.Contains(tab))
            {
                throw new ArgumentException("tab is not a member of this tab controller", "tab");
            }

            if (_activeTab != null)
            {
                _activeTab.CachedGameObject.SetActive(false);

                if (_activeTab.TabButton != null)
                {
                    _activeTab.TabButton.IsActive = false;
                }

                if (_activeTab.HeaderExtraContent != null)
                {
                    _activeTab.HeaderExtraContent.gameObject.SetActive(false);
                }
            }

            _activeTab = tab;

            if (_activeTab != null)
            {
                _activeTab.CachedGameObject.SetActive(true);
                TabHeaderText.text = _activeTab.LongTitle;

                if (_activeTab.TabButton != null)
                {
                    _activeTab.TabButton.IsActive = true;
                }

                if (_activeTab.HeaderExtraContent != null)
                {
                    _activeTab.HeaderExtraContent.SetParent(TabHeaderContentContainer, false);
                    _activeTab.HeaderExtraContent.gameObject.SetActive(true);
                }
            }

            if (ActiveTabChanged != null)
            {
                ActiveTabChanged(this, _activeTab);
            }
        }
        private void MakeActive(SRTab tab)
        {
            if (!_tabs.Contains(tab))
            {
                throw new ArgumentException("tab is not a member of this tab controller", "tab");
            }

            if (_activeTab != null)
            {
                _activeTab.CachedGameObject.SetActive(false);

                if (_activeTab.TabButton != null)
                {
                    _activeTab.TabButton.IsActive = false;
                }

                if (_activeTab.HeaderExtraContent != null)
                {
                    _activeTab.HeaderExtraContent.gameObject.SetActive(false);
                }
            }

            _activeTab = tab;

            if (_activeTab != null)
            {
                _activeTab.CachedGameObject.SetActive(true);
                TabHeaderText.text = _activeTab.LongTitle;

                if (_activeTab.TabButton != null)
                {
                    _activeTab.TabButton.IsActive = true;
                }

                if (_activeTab.HeaderExtraContent != null)
                {
                    _activeTab.HeaderExtraContent.SetParent(TabHeaderContentContainer, false);
                    _activeTab.HeaderExtraContent.gameObject.SetActive(true);
                }
            }

            if (ActiveTabChanged != null)
            {
                ActiveTabChanged(this, _activeTab);
            }
        }
Ejemplo n.º 6
0
 private void TabControllerOnActiveTabChanged(SRTabController srTabController, SRTab srTab)
 {
     Close();
 }