Ejemplo n.º 1
0
    public override void Setup()
    {
        base.Setup();

        // Setup the bookmark target to get-set the enclosure id
        bookmarkTarget.Setup(() => CurrentLevelID, x => CurrentLevelID = (LevelID)x);

        // Clear out any existing options
        levelDropdown.ClearOptions();
        enclosureDropdown.ClearOptions();

        // Loop through all enclosure id's and add them to the list
        foreach (LevelID id in UIParent.Data.Levels)
        {
            TMP_Dropdown.OptionData option = LevelNumberToOptionData(id.LevelNumber);
            // If no option with the same text yet exists, then add it to the dropdown
            if (levelDropdown.options.FindIndex(x => x.text == option.text) < 0)
            {
                levelDropdown.options.Add(option);
            }
        }

        // Update the level dropdown to reflect the current level
        LevelID currentLevel = LevelID.Current();

        levelDropdown.value = currentLevel.LevelNumber;
        levelDropdown.RefreshShownValue();
        OnLevelDropdownValueChanged(levelDropdown.value);

        // Add listeners for the value changed events
        levelDropdown.onValueChanged.AddListener(OnLevelDropdownValueChanged);
        enclosureDropdown.onValueChanged.AddListener(OnEnclosureDropdownValueChanged);
    }
Ejemplo n.º 2
0
    public override void Setup()
    {
        if (!IsSetUp)
        {
            base.Setup();

            // Setup the bookmark target
            bookmarkTarget.Setup(() => currentTab, t => SelectTab((NotebookTab)t));

            // Get all notebook tabs
            NotebookTab[] tabs = (NotebookTab[])System.Enum.GetValues(typeof(NotebookTab));

            foreach (NotebookTab tab in tabs)
            {
                // Instantiate the prefab for this tab
                GameObject tabObject = Instantiate(tabPrefabs.Get(tab), pagesRoot);
                tabObjects.Set(tab, tabObject);

                // Create a notebook tab select button for this tab
                NotebookTabSelectButton button = Instantiate(buttonPrefab, parent.transform);
                button.Setup(tab, parent, OnTabSelected);
                buttons.Add(button);
            }

            // Select the home tab by default
            SelectTab(NotebookTab.Home);
        }
    }