Problem when saving through OnClick

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
Psinamen
Posts: 1
Joined: Thu Sep 14, 2017 6:36 pm

Problem when saving through OnClick

Post by Psinamen »

Greetings!
I bought ES2 a few days ago and I've been enjoying it quite a bit.
However I have a problem now.

My game Loads and Saves perfectly through keys (As in, all objects with info I want to save, save with F7, and load with F8).

However today I made a GUI menu, and when the save button is pressed, Unity freezes for a few minutes. It eventually saves, but it takes a lot of time, and
it froze a couple times, losing me a fair bit of work. Now, I doubt this is due to having to save a lot of data, since it saves instantly with F7, and it has to
save no more than 30 objects. Wanted to know if you could spot a problem in the way I'm donig this.

My setup is as it follows.

I have a MenuSystemScript that is statick : public static MenuSystemScript Only { get; set; }
Then I have about 20 copies of the same object with this line: MenuSystemScript.Only.SaveButton.onClick.AddListener(Save);

They have the save function they are executing : public void Save() { ES2.Save(VariabletoSave, MyID + ".txt"); }

Again, this works wonders with a key, but not when pressing a button. Any help is welcome!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem when saving through OnClick

Post by Joel »

Hi there,

We've not had any reports of any issues using Easy Save inside of an onClick event, and there's no code within Easy Save which would make it act any different within an onClick event.

You might want to attempt to save with a single listener which iterates through your objects and calls the Save method, rather than having a separate listener for each object, as there is an overhead with regards to creating triggering them.

You'll also want to make sure each listener is only being created once; I've seen it before where people have added listeners in events which are called multiple times throughout a scene, causing a huge number of unnecessary listeners to be added.

If you create a very basic project which replicates the error and PM me the link then I'll be happy to take a look at it. This would need to be a basic project with minimal game logic.

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