Hey guys! I am making a cheesy 2D platformer, and for some reason, it is saying that the text fields are null, which is odd, because I specifically give them values. Here is the code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LevelUp : MonoBehaviour {
//The text stating that the player leveled up
public GameObject levelText;
//The button GameObject that the user can click
public Button[] BubbleText = new Button[2];
//The text on the buttons
public Text[] text = new Text[2];
//The string of text options that the user can pick from
public string[][] RogueLvl = new string[3][];
// Use this for initialization
void Start () {
//Some bug testing
//This doesn't show up, so BubbleText[0] is not null
if(BubbleText[0]==null)
{
print("BubbleText[0] is null");
}
//Assigning the Text object to the text on the buttons
text[0] = BubbleText[0].gameObject.GetComponent<Text>();
text[1] = BubbleText[1].gameObject.GetComponent<Text>();
//Temporary statements, to be later upgraded with actual sentences
RogueLvl[2][0] = "Statement1";
RogueLvl[2][1] = "Statement2";
}
// Update is called once per frame
void Update () {
}
void Rogue(int l)
{
for(int i =0; i<RogueLvl.Length; i++)
{
//Enabling the gameObjects in the scene
BubbleText*.gameObject.SetActive(true);*
//Some bug testing, the first statement Returns 2, the second one returns 0;
print("L is " + l);
print("I is " + i);
//If text is null, then this print statement fires
//THIS STATEMENT IS TRUE, so it prints "Text is null"
if(text*==null)*
{
print(“Text “+i+” is null”);
}
//Assigning the statement to the text field
//This is the line where I get the error
text_.text = RogueLvl[l]+“”;
}
}
Any help would be awesome, and thanks in advance everyone _