Page 1 of 1

Simple save - Extremely Slow

Posted: Thu Dec 28, 2017 8:57 am
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");
    }

Re: Simple save - Extremely Slow

Posted: Sat Dec 30, 2017 3:15 pm
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

Re: Simple save - Extremely Slow

Posted: Sun Jan 07, 2018 12:14 am
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!

Re: Simple save - Extremely Slow

Posted: Sun Jan 07, 2018 12:16 am
by Joel
No problem, glad to be of assistance!

All the best,
Joel