void DrawLevelListButtons() { // Show Append button EditorGUILayout.Space(); Rect controlRect = EditorGUILayout.GetControlRect(); controlRect.height += (VerticalMargin * 2); if (GUI.Button(controlRect, "Append new scenes in Build Settings to All Levels list") == true) { // Actually append scenes to the list SceneTransitionManager manager = ((SceneTransitionManager)target); manager.SetupLevels(defaultDisplayName, (defaultFillIn != 0), defaultRevertsTimeScale, defaultLockMode, true); // Untoggle displayDefaults = false; } // Show Replace button EditorGUILayout.Space(); controlRect = EditorGUILayout.GetControlRect(); controlRect.height += (VerticalMargin * 2); if (GUI.Button(controlRect, "Replace All Levels list with scenes in Build Settings") == true) { // Actually append scenes to the list SceneTransitionManager manager = ((SceneTransitionManager)target); manager.SetupLevels(defaultDisplayName, (defaultFillIn != 0), defaultRevertsTimeScale, defaultLockMode, false); // Untoggle displayDefaults = false; } EditorGUILayout.Space(); }
ListButtonScript SetupButtonEventAndName(SceneTransitionManager settings, GameObject buttonObject) { // Add an event to the button ListButtonScript newButton = buttonObject.GetComponent <ListButtonScript>(); SetupButtonEventAndName(settings, newButton); return(newButton); }
Button SetupButtonEventAndName(SceneTransitionManager settings, GameObject buttonObject, int levelOrdinal) { // Add an event to the button Button newButton = buttonObject.GetComponent <Button>(); SetupButtonEventAndName(settings, newButton, levelOrdinal); return(newButton); }
public override void Hide() { bool wasVisible = (CurrentState == State.Visible); // Call base function base.Hide(); if (wasVisible == true) { // Lock the cursor to what the scene is set to SceneTransitionManager manager = Singleton.Get <SceneTransitionManager>(); // Return to the menu manager.LoadMainMenu(); } }
void SetupButtonEventAndName(SceneTransitionManager settings, Button newButton, int levelOrdinal) { // Add an event to the button newButton.onClick.AddListener(() => { OnLevelClicked(settings.Levels[levelOrdinal]); }); // Setup the level button labels Text[] buttonLabels = newButton.GetComponentsInChildren <Text>(true); foreach (Text label in buttonLabels) { label.text = settings.Levels[levelOrdinal].DisplayName; } newButton.name = settings.Levels[levelOrdinal].DisplayName; }
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; }
Button[] SetupLevelButtons(Button buttonToDuplicate) { // Grab the Scene Manager SceneTransitionManager settings = Singleton.Get <SceneTransitionManager>(); // Grab the parent transform from the button Transform buttonParent = buttonToDuplicate.transform.parent; // Check how many levels there are Button[] allButtons = null; GameObject clone = null; if (settings.NumLevels >= 1) { // Add the button into the button list allButtons = new Button[settings.NumLevels]; // Setup the first level button behavior int index = 0; SetupButtonEventAndName(settings, buttonToDuplicate, index); 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(buttonParent); 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, index); SetupButtonNavigation(allButtons[index], allButtons[index - 1]); } // Setup the last button SetupButtonNavigation(backButton, allButtons[allButtons.Length - 1]); } return(allButtons); }
public override void Show(System.Action <IMenu> stateChanged) { // Call base function base.Show(stateChanged); // Check if we need to unlock the next level if (unlockNextLevel == true) { SceneTransitionManager manager = Singleton.Get <SceneTransitionManager>(); GameSettings settings = Singleton.Get <GameSettings>(); if (Singleton.Get <SceneTransitionManager>().NextScene != null) { // Unlock the next level settings.NumLevelsUnlocked = manager.CurrentScene.Ordinal + 1; } else { // Unlock this level (last one) settings.NumLevelsUnlocked = manager.CurrentScene.Ordinal; } } }
public override void Hide() { bool wasVisible = (CurrentState == State.Visible); // Call base function base.Hide(); if (wasVisible == true) { // Lock the cursor to what the scene is set to SceneTransitionManager manager = Singleton.Get <SceneTransitionManager>(); //SceneManager.CursorMode = manager.CurrentScene.LockMode; // Unbind to Singleton's update function if (checkInput != null) { Singleton.Instance.OnUpdate -= checkInput; checkInput = null; } // Return to the menu manager.LoadMainMenu(); } }