FlowCanvas Forums › Support › Possible to save and load global blackboards?
I’m using global blackboards as a way to keep objects persistent between scenes, is it possible to save the blackboard information to a file and load it? I’d like to be able to do this via Flowcanvas rather than writing my own script or using a save asset, but I’m entirely sure if this is posible?
Hey,
Blackboard variables (and Global Blackboard variables) can be serialized and deserialized (save/load) to a string (text) format and thus a file, but there is no “all-in-one” node to achieve this, thus many smaller node will need to be used (for creating the file, serializing the blackboard, writing the string to the file etc), so this can become a bit complex.
On the other hand, there is a simpler solution (which might or might not work in your case), that being the ability to save/load the blackboard variables to/from Unity’s PlayPrefs instead. This can be achieved with the ‘Blackboard.Save’ and ‘Blackboard.Load’ functions respectively. Thus to call those functions in flowcanvas, all you have to do is drag&drop the Blackboard into the flowscript Graph Editor as normal, and from the menu that will popup, select the ‘Blackboard/Save’ or ‘Blackboard/Load’ function. Both Save and Load functions require a “Key” parameter. This is simple a text to identify the save and will need to be unique and the same when you want to Save and Load the same blackboard.
Having said all that, please note that Global Blackboards also have a “Dont Destroy On Load” option (which is checked by default). So, if your goal is to keep the variables consistent between scenes only, then you won’t really need any of the above. If the goal is to keep the variables consistent between entirely different game sessions instead (like a save/load system), then the solution stated above is indeed useful.
Let me know if the above works for you.
Thanks š
Join us on Discord: https://discord.gg/97q2Rjh
Hey, Blackboard variables (and Global Blackboard variables) can be serialized and deserialized (save/load) to a string (text) format and thus a file, but there is no āall-in-oneā node to achieve this, thus many smaller node will need to be used (for creating the file, serializing the blackboard, writing the string to the file etc), so this can become a bit complex. On the other hand, there is a simpler solution (which might or might not work in your case), that being the ability to save/load the blackboard variables to/from Unityās PlayPrefs instead. This can be achieved with the āBlackboard.Saveā and āBlackboard.Loadā functions respectively. Thus to call those functions in flowcanvas, all you have to do is drag&drop the Blackboard into the flowscript Graph Editor as normal, and from the menu that will popup, select the āBlackboard/Saveā or āBlackboard/Loadā function. Both Save and Load functions require a āKeyā parameter. This is simple a text to identify the save and will need to be unique and the same when you want to Save and Load the same blackboard. Having said all that, please note that Global Blackboards also have a āDont Destroy On Loadā option (which is checked by default). So, if your goal is to keep the variables consistent between scenes only, then you wonāt really need any of the above. If the goal is to keep the variables consistent between entirely different game sessions instead (like a save/load system), then the solution stated above is indeed useful. Let me know if the above works for you. Thanks
That’s really great information, I feel like I’m on the right track! Using PlayerPrefs sounds very convenient, out of curiosity, how much work is involved with saving to an individual file instead of the registry? Can it still be done from FC, or might it require a custom script to handle the serialization? You mentioned creating the file, serializing the blackboard, writing the string to the file, is this reasonably simple to do within Flowcanvas?
Hello again,
Yes, it is possible to be done with FC as well. Here is an example of how:
š
Join us on Discord: https://discord.gg/97q2Rjh