Page 1 of 1

AutoSave does not save fast enough on Android

Posted: Thu Apr 02, 2020 6:34 pm
by AdamUhh
Hi!

The project I'm working on was built into an apk and imported to my android device. Save Event is set to 'On Application Quit', and I've noticed that when I Instantiate a new object and leave the application, It needs roughly 6 seconds before AutoSave saves everything I've done. Only after the 6 seconds are up that I can close the Application.
As you can see, the problem is that it takes too long to save, and I usually close down the application, using Samsung's 'Close All' feature, immediately after I'm done.

And so, is there anyway i can reduce this timing?
Is this due to the amount of Objects I have the Autosave Script on?
Help pls :D

P.S - This does not happen on Unity.

Thanks in Advance!
Adam.

Re: AutoSave does not save fast enough on Android

Posted: Fri Apr 03, 2020 7:25 am
by Joel
Hi there,

If it's taking a while to save this is most likely due to the amount of data you're saving. In this case you may need to be more selective about what you save, rather than using Auto Save to store entire GameObjects.

There's an example of saving and loading prefab instances using code here, which will allow you to ensure that only the required data is saved, and that data is saved in the most efficient manner. This is only provided as an example so you will need to modify it for your purposes, but it's fully commented so should give you an understanding of how this would work.

All the best,
Joel

Re: AutoSave does not save fast enough on Android

Posted: Fri Apr 03, 2020 2:56 pm
by AdamUhh
Hey!

Thanks for the quick response!

Is the example you were talking about this? First: https://moodkie.com/forum/viewtopic.php?f=16&t=1438
Or this? Second: https://docs.moodkie.com/easy-save-3/es ... 0instances

I've tried both of them, with the first one not saving my text, as well as only saving one prefab(Clone). It also deletes the prefab(Clone) if I press ANY button in my canvas, which I find strange.

As for the second one, I'm having trouble Saving and Loading the prefab(Clone) with only the data that I need (which is just Text that's inside a child)

Could you give me anymore tips? Sorry for bothering you with something so simple

Thanks!

Re: AutoSave does not save fast enough on Android

Posted: Sun Apr 05, 2020 8:11 am
by Joel
Hi Adam,

Apologies, it looks like the link didn't apply in my post. The example I was talking about was this one. Please could you private message me with a basic project which replicates this so I can see what is happening at my end?

All the best,
Joel

Re: AutoSave does not save fast enough on Android

Posted: Wed Apr 08, 2020 12:42 am
by AdamUhh
Hey man,

I've been at this for awhile and I managed to save everything using the example you gave me as a base. It now only saves string and nothing else. At runtime it instantiates prefabs and the corresponding data is loaded into them, but even with all this, it still does not manage to save most of the time when I close the app. There was also one time where It managed to save, and the next time I opened the app, it reverted back to the state before it was saved.

Any clues?

Thanks,
Adam

Re: AutoSave does not save fast enough on Android

Posted: Wed Apr 08, 2020 7:14 am
by Joel
Hi Adam,

It sounds like this might be that the save event isn't being called on Android. What events are you saving your data on?

Also if you haven't done so already, would you be able to hook it up to a Save and Load button (rather than having it save in Unity events) and see if it works when using them?

All the best,
Joel

Re: AutoSave does not save fast enough on Android

Posted: Wed Apr 08, 2020 3:04 pm
by AdamUhh
Hi!

I finally managed to make it work, I had to add OnApplicationPause and OnApplicationFocus, not just OnApplicationQuit. Now after some testing, all my data seems to stay.

Thanks a lot for the tips and example you gave me :D

Thanks a bunch,
Adam

Re: AutoSave does not save fast enough on Android

Posted: Wed Apr 08, 2020 3:06 pm
by Joel
Glad that's working for you now Adam :)

All the best,
Joel