Skip to content

Instantly share code, notes, and snippets.

@SiarheiPilat
Last active May 9, 2021 18:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiarheiPilat/4d0f9c8967f1d3b95a2f71c0246f91e8 to your computer and use it in GitHub Desktop.
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.
#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