Mesh filter set to null

Discussion and help for Easy Save 3
Post Reply
thecodehermit
Posts: 10
Joined: Wed Nov 25, 2020 8:12 pm

Mesh filter set to null

Post by thecodehermit »

Hi.

I have a big "Level_Data" gameobject containing other gameobjects.
I am trying to save level_Data and then load it.

However I am having problems with loading some of the children inside "Level_Data".
Some of them are static gameobjects and they loose their Mesh filter reference on load.

Code: Select all

ES3.Save("level_Data", level_Data, "Save_Files/" + _save_file_Name + ".es3");
.....
ES3.Load("level_Data", "Save_Files/" + save_file_Name + ".es3", level_Data);
How can I avoid this ?
I dont really need to save the static gameobjects so it will be fine if there is some way to ignore saving them.
I tried disabling the static type for gameobjects inside the easy save menu, but that resulted in a cast exception error when saving.
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: Mesh filter set to null

Post by Joel »

Hi there, and thanks for getting in contact.

Unfortunately it’s not possible for me to understand what your issue is from what you’ve said. Please could you replicate the issue in a new project with a simple scene and private message it to me instructions.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thecodehermit
Posts: 10
Joined: Wed Nov 25, 2020 8:12 pm

Re: Mesh filter set to null

Post by thecodehermit »

I have been trying to replicate it on new project for almost 3 hours already and it isnt happening there... I also stripped down my main project out of everything besides easy save and the 2 gameobjects.... and it saves and loads without a problem....
I just cant replicate it in a simple project -_-

Basically the simplistic version is when I load a static gameobject it looses its mesh filter data on load.

I will send you a video in PM , maybe you can get an idea why is that happening.
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: Mesh filter set to null

Post by Joel »

Thanks for sending the video.

You appear to have Warnings disabled in the console, which I'm almost certain will contain a warning telling you that the Mesh with the reference ID contained in the data does not exist, so cannot be loaded by reference.

This can be for a number of reasons:
  1. The Mesh isn't a dependency of your scene prior to runtime, so it's never added to the manager. In this case right-clicking the Mesh in the Assets panel and selecting Easy Save 3 > Add References to Manager will resolve the issue.
  2. The Mesh is a dependency of your scene, but you've disabled Auto Add References to Manager in Tools > Easy Save 3 > Settings. Again, right-clicking the Mesh in the Assets panel and selecting Easy Save 3 > Add References to Manager will resolve the issue.
  3. The Mesh is generated or copied at runtime: for example, accessing a MeshFilter's 'mesh' property rather than it's 'sharedMesh' property will create a copy of the Mesh which will have a reference ID which won't exist between sessions. In this case you would need to save the Mesh using a separate ES3.Save call, and load it before loading anything which references it to ensure that the reference exists before loading.
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thecodehermit
Posts: 10
Joined: Wed Nov 25, 2020 8:12 pm

Re: Mesh filter set to null

Post by thecodehermit »

Ty, you were right about the first warning. I tried point 1 and 2 from what you said, but it is still not working correctly. I dont really get why this happens only on static objects. And why it doesnt happen on the simpler projects...

The two gameobjects aren't being generated or modified on start. At least I dont think so... It could be that some plugin or smth is doing exactly that. Do you know of any way to find that for sure ?
I also set the FBX mesh to read/write = true.
Here are few more warnings, maybe they can help.

This is on the first play. I save without errors. Then load and get the warning bellow. The static object has not lost its mesh here.
on first load.png
on first load.png (24.6 KiB) Viewed 1456 times
Image


And this one is when I enter play mode for second time. I load and get the warnings bellow. Here I loose the static objects mesh.
on second load.png
on second load.png (16.97 KiB) Viewed 1456 times
thecodehermit
Posts: 10
Joined: Wed Nov 25, 2020 8:12 pm

Re: Mesh filter set to null

Post by thecodehermit »

Ok I kind of figured it out.... You got me thinking if something was actually messing with that object from my scene.
So I toggled everything in the scene on and off till I finally found one system that was messing with the static objects. I am not really sure why or what it was doing to affect other objects... Though I did saw it had a plane mesh which was changing to "Combined mesh" on start for whatever reason ...

After getting rid of it everything so far works perfectly.... 2 entire days spend hunting down this critter @_@
In any case thanks for the help !
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: Mesh filter set to null

Post by Joel »

Glad you managed to resolve the issue. Let me know if you run into any other problems.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thecodehermit
Posts: 10
Joined: Wed Nov 25, 2020 8:12 pm

Re: Mesh filter set to null

Post by thecodehermit »

Its me again. I figured out why this was happening. It wasnt a specific script in the scene, but rather unity itself combining all meshes of static objects on start so it improves performance. Not sure why it worked yesterday when I removed that specific script from the scene though...

In any case do you know if it will be possible to just ignore saving/loading of any static child gameobjects ?

EDIT

I managed to exclude saving static gameobjects. I changed stuff from this file ES3Type_GameObject
Can you just tell me how can I set an attribute when calling a save method so I can turn that code on or of.

line 252

Code: Select all

        /*
		 * 	Gets the direct children of this GameObject.
		 */
        public static List<GameObject> GetChildren(GameObject go)
        {
            var goTransform = go.transform;
            var children = new List<GameObject>();

            foreach (Transform child in goTransform) {
                // If a child has an Auto Save component, let it save itself.
                //if(child.GetComponent<ES3AutoSave>() == null)

                if (!child.gameObject.isStatic) {
                    children.Add(child.gameObject);
                }
            }
            return children;
        }
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: Mesh filter set to null

Post by Joel »

Hi there,

You would need to create a static bool variable in the ES3Type_GameObject script which you can use in an if statement to toggle that code, and change that variable from another script depending on whether you want that code to run or not.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thecodehermit
Posts: 10
Joined: Wed Nov 25, 2020 8:12 pm

Re: Mesh filter set to null

Post by thecodehermit »

Joel wrote: Sun Oct 23, 2022 7:45 am Hi there,

You would need to create a static bool variable in the ES3Type_GameObject script which you can use in an if statement to toggle that code, and change that variable from another script depending on whether you want that code to run or not.

All the best,
Joel
Oh I see, I should have thought of that myself. Thanks for the help !
Post Reply