Can't save struct members

Discussion and help for Easy Save 3
Post Reply
lbloom
Posts: 1
Joined: Fri Sep 27, 2019 3:55 pm

Can't save struct members

Post by lbloom »

Hi all,

I am trying to save a struct with child members, and it's not working. This doc page (https://docs.moodkie.com/easy-save-3/es ... ted-types/) says that struct saving is automatic. Here is my code

Code: Select all

public class TestScript
{
    [System.Serializable]
    private struct Data
    {
        [SerializeField]
        private int m_Int;
        [SerializeField]
        private float m_Float;

        public int m_Int2;
        public float m_Float2;
    }

    [SerializeField]
    private Data m_Data;

    private ES3Settings m_Settings;


	private void Save()
	{
        ES3.Save<Data>("m_Data", this.m_Data, this.m_Settings);
	}
 
	private void Load()
	{
        this.m_Data = ES3.Load<Data>("m_Data", this.m_Settings);
	}

	private void Awake()
	{
        this.m_Settings = new ES3Settings();
        this.m_Settings.saveChildren = true;
    }
}
Here is what ends up in the save file.

{"m_Data":{"__type":"TestScript+Data,Assembly-CSharp","value":{}}}

You can see that none of the members are saving. Any help would be appreciated.

Thank you
Les
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Can't save struct members

Post by Joel »

Hi Les,

Please could you PM me a basic project which replicates this? I've tried to replicate this with your code, but I don't seem to be getting the same behaviour at my end.

Also just to clarify, the saveChildren variable in ES3Settings is for saving children when saving GameObjects.

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