Resources.Load prefab from outside start or update

Hi ! I have a weird bug in my app that I really don’t understand.
To make it simple, I have a server that send JSON message to tell me if I should spawn a monster. This message includes the prefab name and the position. I use Resources.Load to get the monster and then I will Instantiate it.

The prefab “LizardMan.prefab” is in Assets/Resources.
If in the Start() function I put :

Debug.Log("Try to load from start");
GameObject lizard = Resources.Load<GameObject>("LizardMan") as GameObject; 
Debug.Log("Loaded !");

I get the message “Loaded” and my lizard variable is not null. Great !
NOW, I put this code in the callback of JSON message reception.

Debug.Log("Trying to load "+entity.model);
GameObject model = Resources.Load<GameObject>(entity.model) as GameObject;
Debug.Log("Model prefab loaded");

The first print is done and display “Trying to load LizardMan”.
BUT, the second log print is not displayed. There are no errors aswell. Like the function just done an Exit and good bye.

Any idea of what I’m doing wrong ? Thank you !

Okay … Nevermind.
I’ve put a try/catch to see if something was returned. Sometimes I forget the basics :smiley:

Here is the catched error.

UnityEngine.UnityException: Load can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.

So yeah, I have to load my prefab from somewhere else.