- Home /
Question by
AdhamT · Nov 12, 2015 at 05:09 PM ·
arraynull reference exceptioninstances
NullReferenceException with a text array
Hi !
This is my code
public Text [] Texts;
void Update ()
{
Texts [0].text = Player.SelectedObject.ObjectName;
}
and whenever I start the game I get the NullReferenceException error.
Any Ideas ?
Thanks in Advance
Comment
The array Texts is never initialized.
https://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx
Answer by gjf · Nov 12, 2015 at 05:09 PM
you need to initialize each element of the Texts
array (and set its size,etc.)
Your answer
Follow this Question
Related Questions
Assigning instances of the same script to a array-member in the Inspector 0 Answers
how to create rigidbody2d array? 0 Answers
Can an Instance Array Recognize Separately Named Instances? 0 Answers
I dont know why im getting a null reference exception 1 Answer
2d Array on mesh presented reversed or backwards? FIXED 1 Answer