How do I convert This GUI script to Unity UI?
So I have this script for character creation in my rpg but it uses the old GUI. I want to convert this script some how so that it uses the new Unity UI, however I'm not sure how please help. My script:
using UnityEngine; using System.Collections;
public class CreateNewCharacter : MonoBehaviour {
private BasePlayer newPlayer;
private bool isRogueClass;
private bool isWarriorClass;
private bool isThiefClass;
private bool isSoldierClass;
private string playerName = "EnterName";
// Use this for initialization
void Start () {
newPlayer = new BasePlayer();
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
playerName = GUILayout.TextArea (playerName, 15);
isRogueClass = GUILayout.Toggle (isRogueClass, "Rogue");
isWarriorClass = GUILayout.Toggle (isWarriorClass, "Warrior");
isThiefClass = GUILayout.Toggle (isThiefClass, "Thief");
isSoldierClass = GUILayout.Toggle (isSoldierClass, "Soldier");
if (GUILayout.Button ("Create")) {
if (isRogueClass) {
newPlayer.PlayerClass = new BaseRogueClass ();
} else if (isWarriorClass) {
newPlayer.PlayerClass = new BaseWarriorClass ();
} else if (isThiefClass) {
newPlayer.PlayerClass = new BaseThiefClass ();
} else if (isSoldierClass) {
newPlayer.PlayerClass = new BaseKnightClass ();
}
newPlayer.PlayerLevel = 1;
newPlayer.Constitution = newPlayer.PlayerClass.Constitution;
newPlayer.Intellect = newPlayer.PlayerClass.Intellect;
newPlayer.Strenht = newPlayer.PlayerClass.Strenght;
newPlayer.Perception = newPlayer.PlayerClass.Perception;
newPlayer.Charisma = newPlayer.PlayerClass.Charisma;
newPlayer.Dexterity = newPlayer.PlayerClass.Dexterity;
newPlayer.Luck = newPlayer.PlayerClass.Luck;
newPlayer.Fortitude = newPlayer.PlayerClass.Fortitude;
newPlayer.PlayerName = playerName;
Debug.Log ("Player Name " + newPlayer.PlayerName);
Debug.Log ("PLayer Class " + newPlayer.PlayerClass.CharacterClassName);
Debug.Log ("Class Description " + newPlayer.PlayerClass.CharacterClassDescription);
Debug.Log ("Player Level " + newPlayer.PlayerLevel);
Debug.Log ("Constitution " + newPlayer.Constitution);
Debug.Log ("Intellect " + newPlayer.Intellect);
Debug.Log ("Strength " + newPlayer.Strenht);
Debug.Log ("Perception " + newPlayer.Perception);
Debug.Log ("Charisma " + newPlayer.Charisma);
Debug.Log ("Dexterity " + newPlayer.Dexterity);
Debug.Log ("Luck " + newPlayer.Luck);
Debug.Log ("Fortitude " + newPlayer.Fortitude);
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612090041im_/https://answers.unity.com/themes/thub/images/avi.jpg)