- Home /
Null reference Exception - but it's all there
I reordered prefabs, sounds, materials and everything else in my game project folder, using unity (i've not done this using windows explorer). Now i keep getting the "Null reference exception" error even if every game object is correctly linked to every referenced prefab or sound or anything else. I tried evrything, rename scripts, rename prefabs, relink evrything, but nothing works. What can i do?
What is the Null reference co$$anonymous$$g from (code?) are you using Resources.Load? or GameObject.Find()?
It comes from a GameObject.Find() in a script! What can i do?
Have the GameObjects been placed in your scene? Or are you using scripts to load the objects prior to calling GameObject.Find() ?
Answer by highway900 · Jul 17, 2012 at 11:48 PM
I recently tackled something similar and this may be your problem.
GameObject.Find('objectName')
-- Will only find GameObjects that you have created in your scene or dragged from your prefabs into your scene.
Resources.Load('prefab')
-- Will Load a prefab from your resources folder in your prefab section, if this does not exist you simply need to create a new folder named resources and move the prefab in to this folder. After loading the prefab you can then Instantiate
the GameObject 'prefab' from which you have loaded.
You can now use GameObject.Find('prefab') now that the GameObject has been loaded.
Your answer
![](https://koobas.hobune.stream/wayback/20220613074252im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Object Pool object reference is null? 1 Answer
Accessing other GameObjects Script Variables 2 Answers
NullReferenceException Problem 1 Answer
Need Help With a NullReference Exception 2 Answers