Load texture asset from material

I have a material and a diffusemap is assigned to it , I have unticked material and texture both from pre load , I am loading material at runtime but material.ready is firing before the texture is loaded . is there a way I can get diffuseMap asset from material and then load texture so I can also get texture.ready
or if there is any other better way to do such thing please do let me know

Hi @AnasRahim,

There is an internal list on the material asset or the actual material resource, of any other assets required by it while it’s getting prepared.

The property is called _mapping, try looking for it in your material asset using the debugger and you will find there all referenced assets.

You can grab their ID and load them in time before using that material.


I think I’m having this problem. When launching individual scenes from the editor, my materials work correctly, but if I change scenes, it become really clear that certain textures are not loaded and the material looks way off.

@Leonidas, could you elaborate on what I need to do in order to make sure my textures are ready before the materials say mission accomplished and stop checking for the textures?

That’s a good question, I am not sure when a material asset fires its ready method if that means that all referenced textures have been loaded. You will have to step through with the debugger and check in what order that happens.

What I know is that materials that are loaded for a first time, if they reference textures that haven’t been preloaded, they will fetch and load those textures automatically. But that behavior will happen only once, the first time the material is loaded.

When you change scenes, do you have materials that were used in your first scene?