Hi Chris,
I need to create a custom Remember script for a Diary that I created.
The main thing to "save" is the diary pages, which are ultimately a Sprite array in my Diary component.
I followed the instructions from your tutorials which did make quite a lot of sense.
I attached the script to my Diary Game Object which also has my Diary component (with the sprite array).
When the Sprite array in my Diary game object is back to square one. Also, I placed some console Debugs on the beginning and end of my SaveData function but it doesn't seem they are being called at all. Same for the LoadData function.
Any idea what I might be doing wrong? I wanted to past the code here but it doesn't seem I can do code formatting.
Thanks,
Duarte
Comments
You will certainly have to share the code - you can use http://pasteall.org/ to post formatted code.
However, I would say this is due to your diary not being a scene item. It is instead placed outside of any specific scene, which depending on your Unity version will be explicitly shown as "DontDestroyOnLoad" in your Hierarchy.
The correct way to save such data, is to save it as global data - see this tutorial. AC's own menu data is similarly stored in global memory - nothing scene-related.
You also cannot save non-standard types - so an array of Sprites is not going to serialize (this is now a Unity issue, not AC). You're restricted to standard C# types such as int, string, float, bool. AC gets around this by saving the names of asset files as strings, and loading them in from Resources folders.
When arrays are concerned, AC stores all data into one string and separates items by a special character, such as a pipe (|) character.
For an example of AC saving arrays of non-standard types, see the RememberFootstepSounds component in the latest release.