Here’s my code:
using UnityEngine;
using System.Collections;
public class Characterlist : MonoBehaviour {
public bool createcharacter;
public float scrollbar;
public bool choosecast;
public float scrollbartwo;
public string name = "";
public bool showcharacter;
// Use this for initialization
void Start () {
createcharacter = false;
choosecast = false;
showcharacter = false;
}
// Update is called once per frame
void Update () {
}
void OnGUI ()
{
GUI.Box (new Rect (400, 10, 800, 800), "Character");
if (GUI.Button (new Rect (500, 100, 600, 100), "Create new character"))
createcharacter = true;
if (createcharacter) {
scrollbar = GUI.HorizontalScrollbar (new Rect (30, 40, 100, 20), scrollbar, 1.0f, 5.0f, 1.0f);
GUI.Label (new Rect (10, 10, 100, 40), "Class:");
scrollbartwo = GUI.HorizontalScrollbar (new Rect (30, 90, 100, 20), scrollbartwo, 1.0f, 5.0f, 1.0f);
GUI.Label (new Rect (10, 60, 100, 40), "Race:");
GUI.Box (new Rect (0, 0, 200, 250), "");
if (GUI.Button (new Rect (20, 200 ,150 , 40), "Create character"))
{
createcharacter = false;
showcharacter = true;
if (showcharacter == true)
{
GUI.Box (new Rect (100, 100, 100, 100), "asd");
}
}
}
if (createcharacter) {
if (scrollbar == 4) {
GUI.Label (new Rect (70, 10, 100, 40), "Mage");
}
if (scrollbar == 1) {
GUI.Label (new Rect (70, 10, 100, 40), "Warrior");
}
if (scrollbar < 4 && scrollbar > 1) {
GUI.Label (new Rect (70, 10, 100, 40), "Ranger");
}
if (scrollbartwo == 4) {
GUI.Label (new Rect (70, 60, 100, 40), "Human");
}
if (scrollbartwo == 1) {
GUI.Label (new Rect (70, 60, 100, 40), "Orc");
}
if (scrollbartwo < 4 && scrollbartwo > 1) {
GUI.Label (new Rect (70, 60, 100, 40), "Elf");
}
GUI.Label (new Rect (10, 150, 100, 40), "Name:");
name = GUI.TextField (new Rect (70, 150, 50, 20), name);
}
}
}