Meshes loading in without textures/materials

Discussion and help for Easy Save 3
Post Reply
WileeDarklight
Posts: 4
Joined: Tue Sep 14, 2021 8:21 pm

Meshes loading in without textures/materials

Post 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!

User avatar
Joel
Moodkie Staff
Posts: 3723
Joined: Wed Nov 07, 2012 10:32 pm

Re: Meshes loading in without textures/materials

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

WileeDarklight
Posts: 4
Joined: Tue Sep 14, 2021 8:21 pm

Re: Meshes loading in without textures/materials

Post 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

User avatar
Joel
Moodkie Staff
Posts: 3723
Joined: Wed Nov 07, 2012 10:32 pm

Re: Meshes loading in without textures/materials

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

WileeDarklight
Posts: 4
Joined: Tue Sep 14, 2021 8:21 pm

Re: Meshes loading in without textures/materials

Post 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.

User avatar
Joel
Moodkie Staff
Posts: 3723
Joined: Wed Nov 07, 2012 10:32 pm

Re: Meshes loading in without textures/materials

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

WileeDarklight
Posts: 4
Joined: Tue Sep 14, 2021 8:21 pm

Re: Meshes loading in without textures/materials

Post 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.

User avatar
Joel
Moodkie Staff
Posts: 3723
Joined: Wed Nov 07, 2012 10:32 pm

Re: Meshes loading in without textures/materials

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

Post Reply