Problem with ES3 saving GameObject

Discussion and help for Easy Save 3
Sphisis
Posts: 1
Joined: Tue Apr 03, 2018 10:10 am

Re: Problem with ES3 saving GameObject

Post by Sphisis »

Hey!

Just wanted to pitch in. I'm having the issue also. My unity is 2017.3.1f1 with easy save v2.8.4. I noticed that if I create a new game object instance runtime, it drops the material in a load, but if its created in editor, then it keeps it.

Sam
hawken
Posts: 12
Joined: Fri Mar 02, 2018 6:50 am

Re: Problem with ES3 saving GameObject

Post by hawken »

Sphisis wrote:Hey!

Just wanted to pitch in. I'm having the issue also. My unity is 2017.3.1f1 with easy save v2.8.4. I noticed that if I create a new game object instance runtime, it drops the material in a load, but if its created in editor, then it keeps it.

Sam
Moodkie were able to send me a patch after I sent over a test scene recreating the issue.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with ES3 saving GameObject

Post by Joel »

Sphisis wrote:Hey!

Just wanted to pitch in. I'm having the issue also. My unity is 2017.3.1f1 with easy save v2.8.4. I noticed that if I create a new game object instance runtime, it drops the material in a load, but if its created in editor, then it keeps it.

Sam
Hi there,

As mentioned by hawken, if you PM me over your invoice number, I'll send you an update.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
hawken
Posts: 12
Joined: Fri Mar 02, 2018 6:50 am

Re: Problem with ES3 saving GameObject

Post by hawken »

I wasn't able to get material working as I needed it to with ES3, it's fine for simple _Color or _MainTex properties, but shaders made by shaderforge etc don't seem to retain any information when loaded back in using their custom Properties.

In the end, I am now using resources.load and a reference to the material name, and saving that as a string with ES3 instead, I load the ES3 string and Resources.Load finds the right material to load in.

Could you consider saving custom Property setups in shaders/materials? Or is the above method faster?
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with ES3 saving GameObject

Post by Joel »

Hi hawken,

I understand now. It's not possible to save properties of shaders because Unity provides no method of doing so at runtime. Instead we have to manually use Material.HasProperty and Material.Get*PropertyType* to get known property names.

If you take a look at the ES3Type_Material.cs script (which manages the saving and loading of materials), you might be able to see how to incorporate saving and loading of the custom properties yourself. You will need to know the exact name and type of those properties.

However, I'd recommend loading the Material from Resources as you are doing. Or even more efficiently, creating a script containing references to the materials. Then you can store an index into this array.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Amey
Posts: 5
Joined: Wed Jun 02, 2021 2:05 pm

Re: Problem with ES3 saving GameObject

Post by Amey »

Hi threre,

I recently purchased ES3 and love how simple it is to use. I'm still learning unity and bit new to it. Currently I've been using ES3 to save and load gameobjects in unity 2020.3.4.f1 URP. When I save and load a gameobject in the same scene it works fine but if I try to load a saved gameobject in another scene its materials wont load. In console I have the following warning "Reference for UnityEngine.Material with ID 8420867628827896529 could not be found in Easy Save's reference manager. If you are loading objects dynamically (i.e. objects created at runtime), this warning is expected and can be ignored.". This also happens if I save, then exit play mode, then enter play mode and load the saved gameobject. Is there anyway to fix this?
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with ES3 saving GameObject

Post by Joel »

Amey wrote: Wed Jun 02, 2021 2:18 pm Hi threre,

I recently purchased ES3 and love how simple it is to use. I'm still learning unity and bit new to it. Currently I've been using ES3 to save and load gameobjects in unity 2020.3.4.f1 URP. When I save and load a gameobject in the same scene it works fine but if I try to load a saved gameobject in another scene its materials wont load. In console I have the following warning "Reference for UnityEngine.Material with ID 8420867628827896529 could not be found in Easy Save's reference manager. If you are loading objects dynamically (i.e. objects created at runtime), this warning is expected and can be ignored.". This also happens if I save, then exit play mode, then enter play mode and load the saved gameobject. Is there anyway to fix this?
Hi there,

It would not be possible to load references to things which don't exist in the scene you're loading in. So you would need to ensure that there's a reference to the Material in the scene you're loading in to ensure it can be referenced.

Another cause of this issue is when you're using a renderer's 'material' field to access a Material rather than it's 'sharedMaterial' field. When you access 'material', it creates a copy of the Material with a reference ID which will not exist after you leave the scene.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Amey
Posts: 5
Joined: Wed Jun 02, 2021 2:05 pm

Re: Problem with ES3 saving GameObject

Post by Amey »

Hey Joel,

Sorry for the late reply but thanks a lot! Using shared material fixed my problem. Thanks once again. :D
Post Reply