Last active
May 9, 2021 18:26
-
-
Save SiarheiPilat/4d0f9c8967f1d3b95a2f71c0246f91e8 to your computer and use it in GitHub Desktop.
Cycles through build scenes directly in the editor. Loads scenes in Unity according to their build order, using 'Shift' and left and right arrow keys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
// TODO: if the level is unchecked in build settings, the loop starts over | |
public class ShortcutLevelLoader | |
{ | |
[MenuItem("Level loader/Load previous level &LEFT")] | |
static void LoadPreviousLevel() | |
{ | |
int temp = EditorSceneManager.GetActiveScene().buildIndex - 1; | |
if (temp < 0) temp = 0; | |
EditorSceneManager.OpenScene(EditorBuildSettings.scenes[temp].path); | |
} | |
[MenuItem("Level loader/Load next level &RIGHT")] | |
static void LoadNextLevel() | |
{ | |
int temp = EditorSceneManager.GetActiveScene().buildIndex + 1; | |
if (temp > EditorSceneManager.sceneCountInBuildSettings - 1) temp = EditorSceneManager.sceneCountInBuildSettings - 1; | |
EditorSceneManager.OpenScene(EditorBuildSettings.scenes[temp].path); | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment