Skip to content

Instantly share code, notes, and snippets.

@nicetrysean
Created November 16, 2017 11:26
Show Gist options
  • Save nicetrysean/625ca7adb05f6ba62fdf7ee1867452bb to your computer and use it in GitHub Desktop.
Save nicetrysean/625ca7adb05f6ba62fdf7ee1867452bb to your computer and use it in GitHub Desktop.
Skip scenes with key presses
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