I have 2 scripts,a utility script that is meant to list all gameobjects that might be used by others (to avoid lots of searches) and a script that wants to use this script and use a gameObject’s script component reference.
I have both of my code in start, but when i check the inspector the utility script finds the gameobjects fine, but my 2nd script cannot access them. I try to set a variable to the object reference from my utility script and it shows up as null in inspector. The utility script has this reference fine. When i move the assignment statement to “update” it successfully finds the reference and assigns it from the utility script.
This makes me believe that my start method for my 2nd script is running before my utility script gets a reference. How do i change in what order these two scripts execute so that all my scripts can fetch object references from the utility script AFTER utility script is done executing, and hence avoid null references?
If you need more info just ask. I hope i gave enough.
PS: My script code to locate the utility script works fine, just returns null when it is in “start” method.
Seems a convoluted work around. But the script execution order menu is super useful. They need to advertise this and make it easier to get to, and easier to select scripts in a certain folder. (Right now it shows ALL scripts in assets folder, even extensions to unity or frameworks i have added)
– 1337GameDev