How can I display attributes (Stats) of a playable class (Mage etc) on my Character Creation menu?

Making a game in Unity 5 and I have the Main-Menu, and CharacterCreation-Menu. However in the CharacterCreation-Menu I want it to display the “Warrior” stats and “Mage” stats once I click that class in the menu. How can I do so?

I realize that I can add more Menus with each class stats placed onto the screen with the UI text but that wouldn’t be that very fun, also that I can add a new canvas for each player on the CharacterCreationg_Menu but that would make Everything so hard to see and very messy.

I have a hunch that I should add the necessery information in the “public void Warrior” and “public void Mage” But I cannot figure it out.

Once I press a class in the CharacterCreation_Script:
CharacterCreation-Menu_Script:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class CharacterCreationScript : MonoBehaviour {

// Class Info
public Canvas classInfo;

// Class Buttons
public Button warrior;
public Button mage;

// Buttons
public Button createCharacter;
public Button goBack;

// Use this for initialization
void Start ()
{
classInfo = classInfo.GetComponent();
classInfo.enabled = false;

// Classes
warrior = warrior.GetComponent();
mage = mage.GetComponent();

// Buttons
createCharacter = createCharacter.GetComponent();
goBack = goBack.GetComponent();
}
// Classes
// Warrior
public void Warrior()
{
classInfo.enabled = true;
}
// Mage
public void Mage()
{
classInfo.enabled = true;
}
// Create Character Button
public void CreateCharacter()
{
Application.LoadLevel(“NewGame”);
}
// Go Back Button
public void GoBack()
{
Application.LoadLevel(“MainMenu”);
}

// Update is called once per frame
void Update ()
{

}
}

I get a text popping up on the screen “Class Info”
But it does not contain the information stored in the Player_Classes:

Warrior

using UnityEngine;
using System.Collections;

public class BaseWarriorClass : BaseCharacterClass
{

public BaseWarriorClass()
{
// Basic
CharacterClassName = “Warrior”;
CharacterClassDescription = “Uses melee to crush enemies.”;
//Gold = 100;

// Stats
Health = 100;
Mana = 100;
Stamina = 10;
Strength = 20;
Intelligence = 5;
Armour = 0;
Resistance = 0;
}
}

Mage

using UnityEngine;
using System.Collections;

public class BaseMageClass : BaseCharacterClass
{

public BaseMageClass()
{
// Basic
CharacterClassName = “Mage”;
CharacterClassDescription = “Uses spells to vaporize enemies.”;
//Gold = 100;

// Stats
Health = 100;
Mana = 100;
Stamina = 10;
Strength = 5;
Intelligence = 20;
Armour = 0;
Resistance = 0;
}
}

There is no “Use this component to display class information” you have to do it yourself. I suggest you create a template and turn it on/off when you want to display info and pass it the class information. Then assign the values correctly per each property in the class. No other way around it.

I see. Thank you for the answer :slight_smile:

Maybe I were misunderstood? It feels like what I need does exist in this case. You really mean I need to Place one text for each specific stat? That I cannot just call the ClassStats in and they display easily? So I need to do one canvas for each class, and within each canvas I have a text saying Health = 100 Mana = 100 Stamina = 100 and so on for each text? And then when I press the “warrior” I hide the mage class and display warrior and vice versa?

Move the stats to BaseCharacterClass. Both your Warrior and Mage have the same properties but different values. This makes things easier. Then…

Create one Canvas.
Create an empty GameObject parented to the Canvas.
Create a script called “ViewStats”.
Add using UnityEngine.UI;
[SerializeField] Text m_gold; // Assign in inspector
[SerializeField] Text m_health;

etc.

Create a public method
public void Display(BaseCharacterClass character) {
this.m_gold.text = character.Gold.ToString();

etc
}

When you click on an object…make sure one of your manager scripts has a reference to ViewStats and pass it the info
this.m_viewStats.Display(baseCharacterClass);

Since I am relatively new to this, all you said sounds very complicated. However I have all I need in a “GUI version” and the thought just hit me. Can’t I just convert the code a bit to fit my UI instead?

CreateAPlayerGUI:
using UnityEngine;
using System.Collections;
publicclassCreateAPlayerGUI : MonoBehaviour {

publicenumCreateAPlayerStates
{
CHOOSECLASS, // Display and choose class
STATSALLOCATION, // Allocate skillpoints
FINALSTEPS, // Name and Gender
}

publicstaticCreateAPlayerStates currentState;
privateDisplayCreatePlayerFunctions displayFunctions = newDisplayCreatePlayerFunctions();

void Start () {
currentState = CreateAPlayerStates.CHOOSECLASS;

}

void Update () {
switch (currentState) {
case (CreateAPlayerStates.CHOOSECLASS):
break;
case (CreateAPlayerStates.STATSALLOCATION):
break;
case (CreateAPlayerStates.FINALSTEPS):
break;

}

}

void OnGUI() {
displayFunctions.DisplayMainItems();
if (currentState == CreateAPlayerStates.CHOOSECLASS) {
// Display ChooseClass Function
displayFunctions.DisplayChooseClass();
}

if (currentState == CreateAPlayerStates.STATSALLOCATION)
{
// Display ChooseClass Function
displayFunctions.DisplayStatAllocation();
}
if (currentState == CreateAPlayerStates.FINALSTEPS)
{
// Display ChooseClass Function
displayFunctions.DisplayFinalSteps();
}
}
}

And the DisplayCreatePlayerFunction:

using UnityEngine;

using System.Collections;

publicclassDisplayCreatePlayerFunctions {

// List of Current Classes

privateint chooseClass;

privatestring[ ] chooseClassNames = newstring[ ] { “Warrior”, “Mage” };

// Displays Classes

publicvoid DisplayChooseClass()

{

// List of Toggle_Buttons and each button will be a different class

// When a button is clicked, show class and description

chooseClass = GUI.SelectionGrid(newRect(50, 50, 250, 250), chooseClass, chooseClassNames, 4);

GUI.Label(newRect(450, 50, 300, 300), FindClassInfo(chooseClass));

GUI.Label(newRect(450, 100, 300, 300), FindClassStats(chooseClass));

}

// Find Choose Class

privatestring FindClassInfo(int chooseClass)

{

if (chooseClass == 0)

{

BaseCharacterClass tempClass = newBaseWarriorClass();

return tempClass.CharacterClassDescription;

}

elseif (chooseClass == 1)

{

BaseCharacterClass tempClass = newBaseMageClass();

return tempClass.CharacterClassDescription;

}

return"NO CLASS FOUND";

}

// Find Class Stats

privatestring FindClassStats(int chooseClass)

{

if (chooseClass == 0)

{

BaseCharacterClass tempClass = newBaseWarriorClass();

string tempStats = "Health " + tempClass.Health + “\n” + "Mana " + tempClass.Mana + “\n” + "Stamina " + tempClass.Stamina + “\n” + "Strength " + tempClass.Strength + “\n” + "Intelligence " + tempClass.Intelligence + “\n” + "Armour " + tempClass.Armour + “\n” + "Mana " + tempClass.Resistance;

return tempStats;

}

elseif (chooseClass == 1)

{

BaseCharacterClass tempClass = newBaseMageClass();

string tempStats = "Health " + tempClass.Health + “\n” + "Mana " + tempClass.Mana + “\n” + "Stamina " + tempClass.Stamina + “\n” + "Strength " + tempClass.Strength + “\n” + "Intelligence " + tempClass.Intelligence + “\n” + "Armour " + tempClass.Armour + “\n” + "Mana " + tempClass.Resistance;

return tempStats;

}

return"NO STATS FOUND";

}

// Stat Allocation

publicvoid DisplayStatAllocation()

{

// List of stats with + and - buttons to add stats

// Logic to make sure that you cannot allocate more points than you have

}

// Final Steps

publicvoid DisplayFinalSteps()

{

// Text_Bar where you type your name and a button to choose gender.

}

// Main Items

publicvoid DisplayMainItems()

{

GUI.Label(newRect(Screen.width / 2, 20, 250, 100), “CREATE NEW PLAYER”);

}

}

Sorry for very messy-looknig code but this chat is being great

Jesus… People, learn to use CODE tag.
Just saying…