Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
Created July 22, 2011 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AngryAnt/1099119 to your computer and use it in GitHub Desktop.
Save AngryAnt/1099119 to your computer and use it in GitHub Desktop.
GUI component flipping through the levels of the game.
void OnGUI ()
{
bool enabled = GUI.enabled;
GUI.enabled = enabled && Application.loadedLevel > 0;
if (GUILayout.Button ("Previous"))
{
Application.LoadLevel (Application.loadedLevel - 1);
}
GUI.enabled = enabled && Application.loadedLevel < Application.levelCount;
if (GUILayout.Button ("Next"))
{
Application.LoadLevel (Application.loadedLevel + 1);
}
GUI.enabled = enabled;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment