example: I have a script that instantiate a weapon.
How can i pass prefab in SetWeapon(); or if i have something like this:
I know how to assign prefab from inspector, but how to change it from runtime. And if it is possible I like to avoid my weapons siting in the scene and setting weapon variable by gameObject.Find();
Thanks in advance :P
asked Oct 12 '10 at 08:22 AM
You can do this by making use of the Resources Folder.
From the example on the Resources.Load scripting reference:
Why do you want to do this?
It might be a good idea if you stated your broader goal - why you want to avoid prefab references - because it might help someone give a more helpful answer.
There are many reasons why prefab references are a good way to organise your project, and trying to bypass the way Unity is designed to work is generally not a good idea unless you have a specific reason that warrants it.
answered Oct 12 '10 at 08:37 AM
here is the solution that i make when i rethink the problem. Big thanks to Duck for helping me come with this solution.
answered Oct 12 '10 at 03:09 PM