Debugging giant saves from too many localRefs

Discussion and help for Easy Save 3
Post Reply
AndyNemeth
Posts: 2
Joined: Tue Oct 24, 2023 11:21 am

Debugging giant saves from too many localRefs

Post by AndyNemeth »

Hello,
My initial save file is very large (about 6MB). The vast majority of the save file is dedicated to localRefs for my repeated prefabs. Each prefab has about 200 localRefs, which contain many sprites in the game that are not relevant to the prefab at all.

I cannot find good documentation on how EditorUtility.CollectDependencies works, and removing one component at a time from my prefabs to see what component may be causing the dependencies is not working either (the prefab local ref list often just goes down by 1 ref at a time and ends at about 160 refs, even for an empty gameobject).

How would you recommend debugging this issue?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Debugging giant saves from too many localRefs

Post by Joel »

Hi there,

If localRefs is being stored in your save data then it indicates that you've marked an ES3Prefab Component to be saved. In 99% of cases you shouldn't do this, and it shouldn't be necessary to do so, so I would check that you've not created an ES3Type for ES3Prefab and you've not marked it to be saved anywhere.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
AndyNemeth
Posts: 2
Joined: Tue Oct 24, 2023 11:21 am

Re: Debugging giant saves from too many localRefs

Post by AndyNemeth »

Hey, Thanks for quick response.

It doesn't look like I'm marking it to be saved anywhere. To clarify localRefs is not being written under "components", its being written under "es3Prefab" > "refs". It seems like this is expected behavior so that the system can track files?

I just set up a new project to test this and still had all refs in the save:
1. created a new prefab "Foo" with es3 Prefab > enable auto save
2. In auto save settings, only marked Foo's transform to be saved
3. Pressed play, added two Foo objects to the scene, and closed/saved
4. I observe this save file, with the list of refs:

Code: Select all

"value" : [
		{
			"_ES3Ref" : "8600514134578778879",
			"es3Prefab" : {
				"prefabId" : "3695273640707804215",
				"refs" : {"3051720040638958085":"2297439589250315584","7948384932991801607":"5085491036612723067","5237094326433023990":"6269330931612743452","4722113398776289940":"-1","4343651679476899821":"8075685652905630581","4414814627178860942":"5461174746025363302","1364797288147712990":"907625993237785916","7425385312871474959":"2192182501289706014","6461272237920467063":"5209571230024852691","6059513492319438550":"8600514134578778879","3286969465774080047":"1113220557566348384","7003239665315660931":"932543237297611292","1952857471366242649":"6132120645886549251","1480459223165325880":"4856695011263824522","8199610964835795357":"2522731269286596092","3414612519648731973":"5717404711263472702","5462659251006295343":"7104909095636346369","8485600120355924888":"8571156952905914701"
				}
			},
			"transformID" : 2522731269286596092,
			"components" : [
				{
					"__type" : "Transform",
					"_ES3Ref" : "2522731269286596092",
					"goID" : "8600514134578778879",
					"parent" : null,
					.....
					"siblingIndex" : 3
				}
			]
		}
		....
		
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Debugging giant saves from too many localRefs

Post by Joel »

Hi there,

Ah, it's being saved as refs rather than localRefs, which would indicate something different.

The refs are required to be able to load aspects of the prefab by reference, and will contain a reference ID for every dependency of your prefab and the reference ID assigned to the prefab instance that you're saving. Note that this only contains reference IDs, it doesn't contain the objects themselves.

If you didn't want this to happen then you would need to manage prefabs yourself and save/load using code. You can find an example of this here, though this is only provided as a guide and you would need to modify this for your own purposes:

https://moodkie.com/forum/viewtopic.php?t=1438

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply