Create prefabs on the fly
Hey guys,
So I've only been using Unity for a few days and have got a bit stuck. I have a prefab with some scripts attached to it, but now I want to create this prefab from code and draw it to the screen. It doesnt come up in the code so I cant use the Instantiate method :/
Thanks,
Dom
So I've only been using Unity for a few days and have got a bit stuck. I have a prefab with some scripts attached to it, but now I want to create this prefab from code and draw it to the screen. It doesnt come up in the code so I cant use the Instantiate method :/
Thanks,
Dom
Comments
The first, and probably the quickest, is to expose a variable in the inspector and use Instantiate with this reference.
The second is to drop the prefab in the resources folder in the project hierarchy then use Resources.Load to instantiate it.
Hope this was some help. :)