0
Pending Review

Serialize from BOLT graph

Dalibor 3 years ago updated 3 years ago 7

Is it possible to make entire serialization and save/load from BOLT graph?

Or I need for this use C# and add [Serializable] for any variable I want to save, etc..?

I have found all necessary nodes in BOLT but I don't know how  to add "Serializable" in Graph.

Please check attached picture.


I am probably doing everything wrong ;-)

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Pending Review

What is the error you are getting in the Serialize node? 

It should also appear on the console.

You have message at the bottom of attache picture:

SerilizationException: Type Bolt.Flow machine is not marked as Serializable.

Yeah doesn't have serializable attribute. Not sure I've heard anyone attempting to save out the actual graph like that. Don't know if this will work, but create a new serializable Type of your own. Like this maybe.

using Ludiq;

[Serializable]

public class SerializableFlowGraph {

        [Serialize]

        public FlowGraph flowGraph;

}


Then instead of serializing the graph itself, serialize and deserialize your class. Not sure if this will work, if it'll still do the same because the type being serialized inside is the same, but Serialize is a Ludiq serialization attribute, which would probably be using Full Serializer? Which can pretty much Serialize anything, or so I hear.

There is a node with name BinaryFormatter. Serialize and this node is asking for a graph input.

Is that means that when you provide some Flow graph to this node, that all current data with variables will be stored in some file? I was following Unity C# tutorial for saving data and have tried to do the same in Bolt.

You don't have to bother with this, I have done whole project in bolt and at least saving/loading i can do from C# ;-)

I know for saved variables but they are stored with playerPrefs and I want to give a user/player custom location for storing and exchange of data.

Serializing a flow machine or a flow graph is far from trivial. Bolt uses its own variation of FullSerializer behind the scenes, and many custom attributes to specify how serialization should occur.

Why do you need to serialize the entire graph / machine component? Are you not simply trying to save variables or values for your saved game?

You are right, I have went to totaly wrong direction. Anyway...how do I add Serializable attribute to myVariable (float) with BOLT?

+1

Ok. I've got it. Node BinaryFormater Serialize accepts float variables. Thanks guys for help.