Simple save - Extremely Slow

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
yotingo
Posts: 2
Joined: Thu Dec 28, 2017 8:36 am

Simple save - Extremely Slow

Post by yotingo »

Hi everyone,

I'm trying to save a simple list, then load it again on start.

Loading the single list (containing 2 elements) takes ~ 30 seconds.
Saving the same list takes ~ 10 seconds.
Is this normal?

My code runs perfectly without the EasySave lines.

Here is what I'm attempting:

Code: Select all

private List<AudioClip> songList = new List<AudioClip>();

void Start()
    {
        if (ES2.Exists("Song_List"))
        {
            songList = ES2.LoadList<AudioClip>("Song_List"); 
        }
    }

void SaveFunction()
    {
        songList.Add(song);
        S2.Save(songList, "Song_List");
    }
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Simple save - Extremely Slow

Post by Joel »

Hi there,

This takes a while because you're saving/loading AudioClips, which must each be encoded before being serialised.

If the AudioClips themselves do not change, you should consider storing a reference to these rather than the AudioClip themselves. The easiest way to do this is to create an array containing all of your AudioClips. When saving, you save the index of the AudioClip in the array rather than the AudioClip itself. And then when loading, load the index and get the AudioClip at that index in the array.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
yotingo
Posts: 2
Joined: Thu Dec 28, 2017 8:36 am

Re: Simple save - Extremely Slow

Post by yotingo »

Thank you for the reply,

I was able to get it working with your input. I hadn't realized that it was encoding each audio clip. I was under the impression that the clips were only being referenced.

Thanks again!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Simple save - Extremely Slow

Post by Joel »

No problem, glad to be of assistance!

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