NullReferenceException: Object reference not set to an instance of an object
Hello I am still new to unity and have no experience in coding or scripting at all. I was importing assets from the unity store and got this error in the console for a certain asset after importing another.
NullReferenceException: Object reference not set to an instance of an object Tenkoku.Core.TenkokuModule.LoadObjects () (at Assets/TENKOKU - DYNAMIC SKY/SCRIPTS/TenkokuModule.cs:947) Tenkoku.Core.TenkokuModule.Awake () (at Assets/TENKOKU - DYNAMIC SKY/SCRIPTS/TenkokuModule.cs:839)
Here is the script concerning the error the console took me to.
This is the first one from the "LoadObjects" mentioned in the error.
//GET CELESTIAL OBJECTS
worldlightObject = GameObject.Find("LIGHT_World").GetComponent<Transform>(); {Error is here cs:947}
sunlightObject = GameObject.Find("LIGHT_Sun").GetComponent<Transform>();
sunSphereObject = GameObject.Find("SkySphereSun").GetComponent<Transform>();
sunObject = GameObject.Find("Sun").GetComponent<Transform>();
eclipseObject = GameObject.Find("sun_solareclipsefx").GetComponent<Transform>();
moonSphereObject = GameObject.Find("SkySphereMoon").GetComponent<Transform>();
moonObject = GameObject.Find("Moon").GetComponent<Transform>();
moonlightObject = GameObject.Find("LIGHT_Moon").GetComponent<Transform>();
skyObject = GameObject.Find("SkySphere").GetComponent<Transform>();
This is the second one which is the "awake" cs:839 which is mentioned in the console error with it.
//get object references
LoadObjects(); {cs:839 is this one}
//get color map
UpdateColorMap();
//get decoded colors
LoadDecodedColors();
I've tried to look at other peoples posts on unity about this error and still couldn't really undserstand it. Though my guess is that it show as null for the "object" part because it can't find anything for the "awake" line in the script?
Sorry but I have no clue exactly on how to read or write a script. If anyone could help me solve this it would be much appreciated.
Your answer
Follow this Question
Related Questions
Cannot get Addressables to work after successfully build onto Android? 1 Answer
MissingReferenceException at scene unload time 2 Answers
Loading a scene with script loads multiple copies of another scene, the crashes Unity 0 Answers
,Attack and chase range issue 2 Answers
Itween downloaded as a .tar file 0 Answers