Okei I have this array which consists of a Toggle, im fetching all the elements on the canvas. This is then supposed to be clickable and when you click on one of the elements they are passing a text along to a text field that will update the info based on the element that you have selected.
public Toggle[] toggleBut;
void Start () {
populateArray ();
}
private void populateArray()
{
toggleBut = FindObjectsOfType<Toggle> ();
}
public string DisplayHeroInformation(Toggle[] toggleBut)
{
for (int i = 0; i<toggleBut.Length; i++) {
if (toggleBut.Length == 2 && true ) {
CharacterBaseClass tempClass = new JakeTest ();
return tempClass.HeroDescription;
} else if (toggleBut.Length == 1 && true) {
CharacterBaseClass tempClass = new JakeTest ();
return tempClass.HeroDescription;
}
}
return "NO HERO FOUND";
}
void Update () {
HeroDescriptionText.textInfo = DisplayHeroInformation (toggleBut);
}
That above is the first class.
Then for the text class.
public static string textInfo;
Text text;
// Use this for initialization
void Awake () {
text = GetComponent<Text> ();
textInfo = null;
}
// Update is called once per frame
void Update () {
text.text = "Description: " + textInfo;
}
I it only shows the NO HERO FOUND output, I believe this is because it doesnt actually read wheter it is selected or not. Any tips ?