Hello guys ! I’ve search all around the web and can’t find anything to help me …
I’m trying to load a prefab at runtime … but I’m always getting :
NullReferenceException: Object reference not set to an instance of an object
Here is my Assets
folder :
And here is how I’m trying to load it at runtime :
private void loadResources()
{
// Load prefabs
// -- planet 1
planetsRes[0] = Resources.Load("Prefabs/PRF_Planet1") as GameObject;
// -- planet 2
planetsRes[1] = Resources.Load("Prefabs/PRF_Planet2") as GameObject;
// -- planet 3
planetsRes[2] = Resources.Load("Prefabs/PRF_Planet3") as GameObject;
}
Do you have any idea why I can’t access too my prefabs ?
PS : the full error I getting is :
NullReferenceException: Object reference not set to an instance of an object