- Home /
Resources.Load can not get my characters visible
Sorry if this gets twice. But I am not sure if I posted it or not. Because this suddenly got empty when I clicked ask your Question. So here it comes.
My problem is that I cant use Resources.Load and get is visible on my scene. I need to use it, because I need to load in characters into the scene, when a person choose another character in game. this is one of the things I have tried:
GameObject obj = Resources.Load("test", typeof(GameObject)) as GameObject; Instantiate(obj, Vector3.zero, Quaternion.identity); Thank you for your time.
Answer by Meltdown · Mar 22, 2012 at 03:24 PM
Add the following to your script...
[SerializeField] GameObject _myPrefab;
then change it to...
GameObject obj = Resources.Load(_myPrefab, typeof(GameObject)) as GameObject; Instantiate(obj, Vector3.zero, Quaternion.identity);
In the inspector make sure you assign the prefab you want to instantiate to _myPrefab. It should work then no problem. If not, you're doing something wrong.
Thank you! But I can not get it to work. It only make clones when I put it in the Hierarchy. Then it make many clones of it. $$anonymous$$now what I could have done wrong? Or does it need to be in Hierarchy?