- Home /
Resources.Load doesn´t work!
Hello, I have a problem with Resources.Load()
. I made folder called Resources a and i put into it prefab "Player". But when write in code Resources.Load("Player")
, it returns an error.
Are you sure that prefab is causing the nullreferenceexception and not something else on the same line? Try using
Debug.Log(prefab==null);
before line 19
It should work ! Your 'prefabName' string is static. Are you sure that this string is not changed from anywhere else ?
try to load it a different way:
GameObject prefab = Resources.Load("Player") as GameObject;
or
GameObject prefab = (GameObject) Resources.Load("Player");
Try to load "/Ressources/Player" or something like that
Nothing works. I dont know why. I tried add prefab to public GameObject, but it doesn´t allow it.
Answer by Vederant · Jun 03, 2015 at 05:28 AM
You are instatiating this prefab with Vector3 position with y equal to prefab.position.y. Maybe this is the issue?
Your answer
Follow this Question
Related Questions
Some weirdness with recursive instantiation. 2 Answers
Resources.Load() or Prefab manager? 1 Answer
Prefabs are instantiated in editor but not in executable 2 Answers
how Load Prefabs after build 0 Answers
Inventory Instantiation problem 1 Answer