Unity Playmode Testing. Getting Object reference not set to an instance of an object error when trying to access functions from another class.
Hello Everyone,
I have recently been trying to learn the testing framework within unity.
I am trying to access a public object from another class, but I keep getting an object reference not set error. I unsure why I keep getting this error. I cant see what I am doing wrong.
I have attached some images showing where the error occurs and the object I am trying to get access to.
Any help is much appreciated. I really would love to fix this.
Kind Regards, Charlie
Answer by jjrage · Sep 02, 2019 at 02:53 PM
Try to rename your private GameObject gameObject
to private GameObject other_name
Usually gameObject
used as reserved word for indicate current GameObject the script is running on. Also seems like your scripts located in different namespaces which in some cases might be a problem.
Your answer
Follow this Question
Related Questions
Is this a bug? I can't seem to fix it! 0 Answers
Poor FPS/Performance of editor unless two editor windows are open? 0 Answers
Value doesn't change in game when updated. 2 Answers
How to play audio while reloading a weapon ammo in unity 3d C# Scripting ? 0 Answers
Camera Editor,Camera Editor 1 Answer