Saving and Loading from a StateMachine (Visual Scripting)
Posted: Sat May 06, 2023 8:46 am
I have just gotten into Visual Scripting, so this is almost definitely down to me overlooking something. With that said, we are developing a game with a construction mechanic spread across multiple locations. There is a lot of data to save and load and it is done a bit more manually, which ES3 has helped us manage nicely. However, perhaps due to our more manual handling of saving, I can't seem to figure out how to save the state of a StateMachine and load it back. I haven't come across clear documentation as to how to do this on the Unity Visual Scripting side, outside of a comment I came across saying 'use Easy Save 3'.
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:
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
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