- Home /
Question by
danursache · Apr 25, 2021 at 01:56 PM ·
errorbugphotonresources.load
Resources.Load doesn't load prefab in "Resources" Folder
Hi, I'm having a bit of a problem with Resources.Load function. I have a prefab in a "Resources" folder as follows:
Assets/_MyAssets/Resources/Npc
I use Photon network's instantiate function to create my object:
GameObject npc = PhotonNetwork.Instantiate("Npc", waypoint.Position, waypoint.Rotation, 0);
which in turn calls the Resources.Load:
res = (GameObject)Resources.Load(prefabId, typeof(GameObject));
if (res == null)
{
Debug.LogError("DefaultPool failed to load \"" + prefabId + "\" . Make sure it's in a \"Resources\" folder.");
}
Now, the interesting part is that if I rename my prefab, say NpcA, and also change the prefab's name in PhotonNetwork.Instantiate call, it works. But if I restart Unity, the error re-appears.
What am I missing? This issue started to manifest when I upgraded to Unity version 2020.2.2f1.
This is my first time asking a question on the Unity forums, so please let me know if I broke any rules. Thanks.
Comment
Your answer
