Created
November 16, 2017 11:26
-
-
Save nicetrysean/625ca7adb05f6ba62fdf7ee1867452bb to your computer and use it in GitHub Desktop.
Skip scenes with key presses
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
using System; | |
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
namespace SeanHelpsWithThese.Scripts | |
{ | |
public class SceneSkipper : MonoBehaviour | |
{ | |
[Serializable] | |
public class SceneKey | |
{ | |
public KeyCode Key; | |
public int Index; | |
} | |
public SceneKey[] SceneKeys; | |
public void Start() | |
{ | |
DontDestroyOnLoad(this); | |
} | |
public void Update() | |
{ | |
for (int i = 0; i < SceneKeys.Length; i++) | |
{ | |
if (Input.GetKeyDown(SceneKeys[i].Key)) | |
{ | |
SceneManager.LoadScene(SceneKeys[i].Index, LoadSceneMode.Single); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment