예제 #1
0
        ListButtonScript SetupButtonEventAndName(SceneTransitionManager settings, GameObject buttonObject)
        {
            // Add an event to the button
            ListButtonScript newButton = buttonObject.GetComponent <ListButtonScript>();

            SetupButtonEventAndName(settings, newButton);
            return(newButton);
        }
예제 #2
0
        void SetupButtonEventAndName(SceneTransitionManager settings, ListButtonScript newButton)
        {
            // Add an event to the button
            int levelOrdinal = newButton.Index + 1;

            newButton.OnClicked += ((button) =>
            {
                OnLevelClicked(settings.Levels[levelOrdinal]);
            });

            // Setup the level button labels
            foreach (TranslatedText label in newButton.Labels)
            {
                label.TranslationKey = settings.Levels[levelOrdinal].DisplayName.TranslationKey;
            }
            newButton.name = settings.Levels[levelOrdinal].DisplayName.TranslationKey;
        }
예제 #3
0
        ListButtonScript[] SetupLevelButtons(ListButtonScript buttonToDuplicate)
        {
            // Grab the Scene Manager
            SceneTransitionManager settings = Singleton.Get <SceneTransitionManager>();

            // Check how many levels there are
            ListButtonScript[] allButtons = null;
            GameObject         clone      = null;

            if (settings.NumLevels >= 1)
            {
                // Add the button into the button list
                allButtons = new ListButtonScript[settings.NumLevels];

                // Setup the first level button behavior
                int index = 0;
                SetupButtonEventAndName(settings, buttonToDuplicate);
                //SetupButtonNavigation(buttonToDuplicate, backButton);
                allButtons[index] = buttonToDuplicate;
                ++index;

                // Setup the rest of the buttons
                for (; index < allButtons.Length; ++index)
                {
                    // Setup the level button
                    clone = Instantiate <GameObject>(buttonToDuplicate.gameObject);
                    clone.transform.SetParent(levelContent);
                    clone.transform.SetAsLastSibling();
                    clone.transform.localScale    = Vector3.one;
                    clone.transform.localPosition = Vector3.one;
                    clone.transform.localRotation = Quaternion.identity;

                    // Add the button into the button list
                    allButtons[index] = SetupButtonEventAndName(settings, clone);
                    //SetupButtonNavigation(allButtons[index], allButtons[index - 1]);
                }

                // Setup the last button
                //SetupButtonNavigation(backButton, allButtons[allButtons.Length - 1]);
            }
            return(allButtons);
        }