예제 #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
        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.localScale    = Vector3.one;
                    clone.transform.localPosition = Vector3.one;
                    clone.transform.localRotation = Quaternion.identity;
                    clone.transform.SetAsLastSibling();

                    // Push the back button at the bottom
                    backButton.transform.SetAsLastSibling();

                    // 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);
        }
예제 #3
0
        void SetupButtonEventAndName(SceneTransitionManager settings, ListButtonScript newButton)
        {
            // Add an event to the button
            SceneInfo scene = settings.Levels[newButton.Index];

            newButton.OnClicked += ((button) =>
            {
                OnLevelClicked(scene);
            });

            // Setup the level button labels
            foreach (TranslatedTextMeshPro label in newButton.Labels)
            {
                if (label != null)
                {
                    label.SetTranslationKey(scene.DisplayName.TranslationKey, (newButton.Index + 1));
                }
            }
            newButton.name = scene.DisplayName.TranslationKey;
        }