Page 1 of 1

Meshes loading in without textures/materials

Posted: Tue Sep 14, 2021 8:29 pm
by WileeDarklight
Hey guys!

I'm trying to get a large group of GameObjects saved for our in-game Save/Load system. When I load the meshes of our stuff back in, it's all pink (no textures/materials). I tried to add materials/material/sharedmaterials to the MeshRenderer config in ES3 settings but that yields the same thing, plus an error:

Code: Select all

ArgumentNullException: Value cannot be null.
Parameter name: m
UnityEngine.Renderer.set_materials (UnityEngine.Material[] value) (at <bad59441812943c7b8d5a5ba85795810>:0)
ES3Types.ES3UserType_MeshRenderer.ReadComponent[T] (ES3Reader reader, System.Object obj) (at Assets/Easy Save 3/Types/ES3UserType_MeshRenderer.cs:98)
I'm strictly saving and loading everything as a GameObject[], not doing anything else to it. So what would I need to do to get it to save the materials and textures properly?

Thanks!

Re: Meshes loading in without textures/materials

Posted: Wed Sep 15, 2021 7:10 am
by Joel
Hi there,

Are you getting any warnings to console? Also are you accessing the MeshRenderer.sharedMaterial variable in your project at any point?

All the best,
Joel

Re: Meshes loading in without textures/materials

Posted: Wed Sep 15, 2021 2:35 pm
by WileeDarklight
The only warnings I'm getting are the ones that say

Code: Select all

If you are loading objects dynamically (i.e. objects created at runtime), this warning is expected and can be ignored.
And I don't believe we are no. There's a team of us working on this project so I can't say for certain, but everything I see that we're using in this scene doesn't access MeshRenderer.sharedMaterial

Re: Meshes loading in without textures/materials

Posted: Wed Sep 15, 2021 2:52 pm
by Joel
Hi there,

And just to check, there is a reference to the Material in this scene prior to runtime?

All the best,
Joel

Re: Meshes loading in without textures/materials

Posted: Wed Sep 15, 2021 3:10 pm
by WileeDarklight
Yep! the objects in question (houses, sign posts, statues, etc) are all textured as intended when saved. It's only loading them back in that causes the missing materials.

Re: Meshes loading in without textures/materials

Posted: Wed Sep 15, 2021 3:40 pm
by Joel
Please could you create a new, empty project with a very basic scene which replicates the issue and private message it to me with instructions?

All the best,
Joel

Re: Meshes loading in without textures/materials

Posted: Wed Sep 15, 2021 4:42 pm
by WileeDarklight
Hey Joel,

I've done some investigating with another dev more familiar with certain systems and he informs me that;

1) we *are* using sharedMaterials

and

2) the materials are actually pulled in at runtime, so there is no reference to the materials in the scene already.

My mistake, I was not involved in the construction of a few of the building systems for our city builder.

Re: Meshes loading in without textures/materials

Posted: Wed Sep 15, 2021 6:14 pm
by Joel
Hi there,

In this case you would need to save the Material by reference by saving it directly using an ES3.Save call before loading any objects that reference it (assuming it’s a standard material which can be serialised at runtime).

All the best,
Joel