/// <summary>
        /// Sets up a new ui view and adds ui elements if there are any
        /// </summary>
        /// <param name="devUIView">The dev UI view data</param>
        public void SpawnUIView(DevUIView devUIView)
        {
            //Spawn  the tab
            GameObject uiViewTabGO = Instantiate(uiViewTabPrefab) as GameObject;

            uiViewTabGO.transform.SetParent(uiViewTabbar.transform, false);
            uiViewTabGO.name = "tab_" + devUIView.Name;

            //Spawn the view
            GameObject uiViewGO = Instantiate(uiViewPrefab) as GameObject;

            uiViewGO.transform.SetParent(uiViewsContainer, false);

            //Connect tab and view
            GMTab uiViewTab = uiViewTabGO.GetComponent <GMTab>();

            uiViewTab.content = uiViewGO;
            uiViewTabbar.RegisterTab(uiViewTab);

            UIViewController uiViewController = uiViewGO.GetComponent <UIViewController>();

            uiViewController.Initialize(devUIView, uiViewTab);

            uiViews.Add(devUIView, uiViewController);
        }
Exemple #2
0
        public void DeactivateTab(GMTab tab)
        {
            if (activeTab == tab)
            {
                tab.isOn  = false;
                activeTab = null;

                OnValueChanged();
            }
        }
Exemple #3
0
        /// <summary>
        /// Adds a new tab to the tabbar.
        /// </summary>
        /// <param name="tab">Tab.</param>
        public void RegisterTab(GMTab tab)
        {
            tabs.Add(tab);
            tab.Initialize(this);
            RegisterToggle(tab);

            if (activateNewTabsOnAdd)
            {
                ActivateTab(tab);
            }
        }
Exemple #4
0
 /// <summary>
 /// Returns 0 if tab is not registered
 /// </summary>
 /// <param name="tab"></param>
 /// <returns></returns>
 public int GetIndexOfTab(GMTab tab)
 {
     if (tabs.Contains(tab))
     {
         return(tabs.IndexOf(tab));
     }
     else
     {
         return(0);
     }
 }
Exemple #5
0
        /// <summary>
        /// Activates the index of the tab by. Used by management view
        /// </summary>
        /// <param name="index">Index.</param>
        public void ActivateTabByIndex(int index)
        {
            GMTab tab = tabs[index];

            if (tab != null)
            {
                ActivateTab(tab);
            }
            else
            {
                ActivateFirstTab();
            }
        }
        void SpawnTopLevelTab(DataBrowserTopLevel topLevel)
        {
            GMTab tab = Instantiate(tabTemplate) as GMTab;

            tab.GetComponentInChildren <Text>().text = topLevel.topLevelName;
            tab.transform.SetParent(tabbar.transform, false);
            if (!tab.gameObject.activeSelf)
            {
                tab.gameObject.SetActive(true);
            }
            tabbar.RegisterTab(tab);

            tabs.Add(topLevel, tab);
        }
Exemple #7
0
 public void ActivateTab(GMTab tab)
 {
     //Deactivate all tabs and activate new tab
     foreach (GMTab _tab in tabs)
     {
         if (_tab == tab)
         {
             _tab.isOn = true;
         }
         else
         {
             _tab.isOn = false;
         }
     }
 }
Exemple #8
0
        public void ActivateFirstTab()
        {
            if (tabs.Count > 0)
            {
                GMTab firstTab = tabs.FirstOrDefault();

                if (firstTab != null)
                {
                    ActivateTab(firstTab);
                }
                else
                {
                    ActivateTab(tabs[0]);
                }
            }
        }
Exemple #9
0
        public void RemoveTab(GMTab tab, bool destroy = false)
        {
            //activate tab in front
            int index = tabs.IndexOf(tab);

            if (tabs.Count > 0)
            {
                ActivateTabByIndex(index - 1);
            }

            //Remove tab
            tabs.Remove(tab);
            if (destroy)
            {
                Destroy(tab.gameObject);
            }
        }
Exemple #10
0
 public void SetOrderForTab(GMTab tab, int index)
 {
     tab.transform.SetSiblingIndex(index);
     tabs.Remove(tab);
     tabs.Insert(Mathf.Clamp(index, 0, tabs.Count - 2), tab);
 }
Exemple #11
0
 /// <summary>
 /// This method should only be used by a Tab to register itself as active.
 /// </summary>
 public void SetAsActiveTab(GMTab tab)
 {
     activeTab = tab;
     OnValueChanged();
 }
        public void Initialize(DevUIView uiView, GMTab uiViewTab)
        {
            myView = uiView;
            myTab  = uiViewTab;

            //Set name
            UpdateName(myView.Name);

            //Check if we want to have extension buttons
            extensionButtonGroup.SetActive(uiView.extensionAllowed);

            //Button events
            if (uiView.extensionAllowed)
            {
                addLuaCommandButton.onClick.AddListener(AddLuaButton);
                addLuaExpressionButton.onClick.AddListener(AddLuaExpression);
            }

            applyAllButton.onClick.AddListener(ApplyAll);
            applyAllAndCloseButton.onClick.AddListener(ApplyAllAndClose);

            //Setup buttons if this UI Views is created dynamically from script. If this is not the case deactivate the buttons to rename or archive the ui view.
            if (uiView.createdDynamically)
            {
                saveNameButton.onClick.AddListener(
                    () => {
                    UpdateName(renameInputField.text);
                    ToggleNamingMode(false);
                }
                    );
                renameButton.onClick.AddListener(
                    () => ToggleNamingMode(true)
                    );
                renameInputField.onValueChanged.AddListener(ValidateName);
                archiveButton.onClick.AddListener(ArchiveView);
            }
            else
            {
                renameButton.gameObject.SetActive(false);
                archiveButton.gameObject.SetActive(false);
            }

            //Setup ui elements
            foreach (DevUIElement uiElement in uiView.uiElements)
            {
                SpawnUIElement(uiElement);
            }

            //Add listener
            _eventService.OnEvent <Service.DevUIService.Events.NewUIElement>().Where(u => u.view == myView).Subscribe(evt => {
                if (evt.elem is DevUILuaExpression)
                {
                    SpawnLuaExpression((DevUILuaExpression)evt.elem, evt.inEditMode);
                }
                else if (evt.elem is DevUILUAButton)
                {
                    SpawnLuaButton((DevUILUAButton)evt.elem, evt.inEditMode);
                }
                else
                {
                    SpawnUIElement(evt.elem);
                }
            }).AddTo(this);

            uiView.uiElements.ObserveRemove().Subscribe(e => {
                RemoveUIElement(e.Value);
            }).AddTo(this);

            ToggleNamingMode(false);
        }