Hi guys, i create a script where i can choose between 2 classes and when i choose the class it saves the vase stats in the player, but i use the script below with old UI. Now i know how to create the new UI Canvas/Images/Buttons but i dont get how to script the stats load in character with the new UI button… If can anyone help me i will appreciate.
I just want the same 2 buttons for 2 classes and the start button.
using UnityEngine;
using System.Collections;
public class CharacterSelect : MonoBehaviour
{
public BasicStats[] AllClassStats;
public bool ClassSelectWindow;
public GameObject User;
//public Texture mage;
//public Texture warrior;
// Use this for initialization
void Start ()
{
ClassSelectWindow = true;
}
// Update is called once per frame
void OnGUI ()
{
if (ClassSelectWindow)
{
if (GUI.Button (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 150, 200, 40), "Mage"))
{
AssignBaseStats (0);
//ClassSelectWindow = false;
}
if (GUI.Button (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 40), "Rogue"))
{
AssignBaseStats (1);
//ClassSelectWindow = false;
}
if (GUI.Button (new Rect(Screen.width / 2 - 50, Screen.height / 2 + 50, 100, 30), "Start"))
{
ClassSelectWindow = false;
}
}
}
void AssignBaseStats(int classChosen)
{
var Comp = User.GetComponent<UserStats> ();
Comp.UserClass = AllClassStats [classChosen].UserClass;
Comp.baseAttack = AllClassStats [classChosen].baseAttack;
Comp.baseDefense = AllClassStats [classChosen].baseDefense;
Comp.baseAttackSpeed = AllClassStats [classChosen].baseAttackSpeed;
Comp.baseEvasion = AllClassStats [classChosen].baseEvasion;
Comp.baseHitPercent = AllClassStats [classChosen].baseHitPercent;
}
}