- Home /
Clone a prefab
I have a prefab called Disk in my unity editor. When I try to call it in code like this
GameObject disk = Instantiate(Resources.Load("Disk")) as GameObject;
I get an error saying that the object I'm trying to instantiate is null. Any suggestions?
Answer by PAEvenson · Nov 21, 2012 at 07:55 PM
make sure disk is in the assets/resources folder.
It doesn't have a resources folder, shouldn't it have made one when I made the object?
when you use resources.load those objects needs to be in a resources folder inside the assets folder of the project. If there isnt one there, create it.
Your answer
Follow this Question
Related Questions
Can't retrieve information from GameObject 2 Answers
how to check for GameObject is null in array with random 1 Answer
prefab is instantiating without a script 2 Answers
Acessing scripts in other game objects with prefabs, without using GameObject.Find 1 Answer
How do I assign a prefab reference to a private variable? 1 Answer