Skip to content

Instantly share code, notes, and snippets.

@jakevsrobots
Created November 25, 2013 21:27
Show Gist options
  • Save jakevsrobots/7649201 to your computer and use it in GitHub Desktop.
Save jakevsrobots/7649201 to your computer and use it in GitHub Desktop.
A very simple dialog/conversation system using Unity's GUI functions.
using UnityEngine;
using System.Collections;
public class Conversation : MonoBehaviour {
public GUISkin skin;
string scene = "start";
void OnGUI()
{
GUI.skin = skin;
GUILayout.BeginArea(new Rect(50,50, 250,250));
if(scene == "start")
{
GUILayout.BeginVertical();
GUILayout.Label("Howdy.");
if(GUILayout.Button("O hai."))
{
scene = "hello";
}
if(GUILayout.Button("Where the party is?"))
{
scene = "party";
}
GUILayout.EndVertical();
}
else if(scene == "hello")
{
GUILayout.BeginVertical();
GUILayout.Label("Cool talk to you later.");
GUILayout.EndVertical();
}
else if(scene == "party")
{
GUILayout.BeginVertical();
GUILayout.Label("I would also like to know.");
GUILayout.EndVertical();
}
GUILayout.EndArea();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment