We have implemented something similar for other components already, usually inside the component with data to serialize. The backend keeps a list of ISaveLoadComponent and performs a serialize/deserialize to the matching components. This is used in part to separate the save into separate files, keeping the data organized and the files from getting too massive. The only issue left is figuring out what data to save/serialize and how to load/deserialize it back into the StateMachine:
Code: Select all
public class SaveLoadStateMachine : MonoBehaviour, ISaveLoadComponent
{
[ES3NonSerializable] public StateMachine stateMachine;
[ES3Serializable]
public SerializationData stateMachineData
{
get
{
return stateMachine.Serialize();//??? This seems like it will be trying to serialize the state machine itself, not the current state data
}
set
{
//stateMachine.CurrentState.Deserialize(value);//something like this?
}
}
[ES3NonSerializable] [SerializeField] private string m_SLC_UniqueName = "StateMachine";
public string SLC_UniqueName => m_SLC_UniqueName;
public bool SLC_IncludesReferences => false;
}
There is no time pressure here, as we are looking into making sure we can save/load to a state machine before we commit to implementing any StateMachine.
Thank you