I’m Trying To Load Prefabs By Using Resources.Load Because From ‘GameFolder\Assets\Resources\Prefabs’ In The Script That Uses Them Because It Won’t Be By Default In The Scene And Linking The Prefabs In The Inspector Doesn’t Work Either.
When I Run The Game The Console Tells Me The Prefabs Been Loaded But When I Instantiate One Of Them The Console Tells Me The Prefab Is Null.
What I’m Doing Wrong? Is Possible To Load Them In This Way Or Should Delegate The Load To A Sub-Script Pre-Existent In The Scene?
First off, why arent you just dragging the prefabs into the inspector and assigning them that way?
Two, what does the inspector tell you at runtime with regards to the Prefabs you are loading from Resources? Are they assigned after Start or are they empty?
Third, I am not entirely sure that you can just load something from resources and store it as a gameobject for an entire scene. I have not tried this as I Instantiate them and pass the Resources.Load into the parameters of the Instantiate function. This is how i do it at Start when i load in the objects at runtime:
string prefab = "Prefabs/Objects/" + substationData.objList[count];
Instantiate(Resources.Load(prefab) as GameObject, newObj.transform);
Obviously, ignore the +substationData.objList[count] since it actually is in a loop. But i take the string and and then call Resources.Load(string) as GameObject.
Fourth, why is every first letter of your post capitalized? I understand english may not be your first language but still, you should avoid that.
Fifth, screenshots of code are not a thing. I was nice and tried to read the tiny code and could sorta figure it out, but some people on here wont even both. You can edit your post and then use the text ribbon to use Code Tags and copy/paste the code in.
I’m not dragging the prefabs to the inspector cuz as said before the script it’s not in the scene, it’s called later and since the script isn’t attached to any object in the scene i cannot see it in the inspector.
Anyways you were right, seems prefabs cannot be stored permanently in this way. Done it using your method and worked, thanks for your help