Reference Manager just for using prefabs?

Discussion and help for Easy Save 3
Post Reply
paulodaktor
Posts: 6
Joined: Mon Apr 19, 2021 11:28 pm

Reference Manager just for using prefabs?

Post by paulodaktor »

Hey,

I'm creating an strategy game for mobile and I'm kinda struggling finding out which way is the best to balance between ingame performance and load/save times. First of all there is no auto-save, so the user can just save his game, when he is clicking on a "save"-button (meaning the time to actually save or load is not that important...or so I thought).

My first approch was to use the reference manager. Save a lot of stuff by references and with prefabs (for example resources, soldiers, buildings, etc).
But after like 5 minutes in the game, there were already tens of thousands of references and the ingame performance was getting poor. On the other hand, saving only took a couple of seconds.

My second approach was to save everything by value and don't use prefabs, so I can get rid of the Reference-Manager entirely. This led to saving times way over a couple of minutes. But hey, the ingame-performance was not getting worst over time...

So my next thought was to save everything by value (I use a lot of scriptable objects, so I can just save an int or whatever to reference this manually back to the scriptable object) and only reference prefabs. The problem I'm having with this, is that I can obiously not use ES3-Prefabs, without the Reference Manager. My current, really dirty solution is to "Clear();" the ReferenceManager every couple of seconds, so I don't get thousands of useless references, but can save my prefabs. Is there an possibility to maybe de/activate the referenceManager just, when I'm saving/loading. Or maybe deactivate the auto-updating references, so I don't have to Clean it manually.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Reference Manager just for using prefabs?

Post by Joel »

Hi there,

Just to check, have you followed the Improving Performance guide?

https://docs.moodkie.com/easy-save-3/es ... rformance/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
paulodaktor
Posts: 6
Joined: Mon Apr 19, 2021 11:28 pm

Re: Reference Manager just for using prefabs?

Post by paulodaktor »

Yes I have and I'm currently using Caching, which was a big improvement.
But there is just a huge amount of data to save (if I can't prefab them). Foreach Soldier, Worker, Resource, etc. I have to save coordinates, internal data, etc :/
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Reference Manager just for using prefabs?

Post by Joel »

The issue is likely the volume of data you're saving, which unfortunately there isn't any way around apart from to save less data.

Have you tried using Unity's Profiler to see exactly what part of the process is taking the most time?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
paulodaktor
Posts: 6
Joined: Mon Apr 19, 2021 11:28 pm

Re: Reference Manager just for using prefabs?

Post by paulodaktor »

I believe the main problem are the soldiers. There are a lot of them and when I can't save prefabs I have to save each one indipendently.
When I save everything by value and don't use prefabs, the file itself is at least 100mb large (uncompressed, no encryption). Saving this huge amount of data is just not an option, especially on mobile devices.

Apart from that I just finished my dirty approach by using the Reference Manager JUST for the prefabs, meaning I clean it every 10 seconds. Do you see any possibility to just gather the prefab references and not the one in the scene? Because I'm quite happy with the balance between ingame-performance and loading/saving time right now (when I save everything by value, but still use prefabs).
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Reference Manager just for using prefabs?

Post by Joel »

Hi there,
There are a lot of them and when I can't save prefabs
Just to check, why can't you save prefabs?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
paulodaktor
Posts: 6
Joined: Mon Apr 19, 2021 11:28 pm

Re: Reference Manager just for using prefabs?

Post by paulodaktor »

I mean I'm unable to save Prefabs with the "ES3Prefab" Component, because it would need the Reference Manager to work properly, right?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Reference Manager just for using prefabs?

Post by Joel »

Hi there,

Just to check, when you have the reference manager in your scene, how have you determined that it is causing performance issues? The reference manager is just a Dictionary which contains references to things which are already referenced by your scene, so shouldn't cause any significant slow down.

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