weird Object reference not set to an instance of an object error, help
Hello, I'm new here, not with much experience with coding, i was working with some Script everything was working i take a little rest, when i come back, i got this error and I don't get what is wrong. In the script I create the Int[,] I made it equal to another int[,], but when i try to access it it tell me that it doesn't exist.
Here an image of the error and the code to show what's going on
I already checked and the P2Lab.LabMatriz exist, so there is not the problem. All point to MatVirt variable, but i really don't get why It doesn't exist in that point.
Well i found part of the problem, when this Start() happen, P2Lab.LabMatriz is null, on the other script I fill LabMatriz also in an start() Function, the two scripts are attached to the same object, It was working before, so i don't get why its not right now, so ¿how to get one script work before the other? ¿Awake?
thanks
Answer by vansulu · Apr 06, 2017 at 07:51 PM
Realise you've probably sorted this out but I had a similar issue that was worked out via Edit->Project Settings->Script Execution Order
Answer by Cuttlas-U · Apr 06, 2017 at 08:10 PM
u can use Invoke to call the other lines a bit later and the order will be set in that space;
void Start()
{
/*
your first code lines
*/
Invoke("SecondPart", 0.001f);
}
public void SecondPart()
{
/*
your second code lines
*/
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612105237im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
JS NullReferenceException: Object reference not set to an instance of an object 1 Answer
javascript NullReferenceException: Object reference not set to an instance of an object 0 Answers
NullReferenceException: Object reference not set to an instance of an object 0 Answers
Can´t change Personal details 1 Answer
Number overflow 1 Answer