Save/load Unity game object reference in blackboard not working

NodeCanvas Forums Support Save/load Unity game object reference in blackboard not working

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #15771

    I have a bound blackboard with a single variable of type Unity Transform. When I save the blackboard it has a value (i.e. MyGameObject). When I load the blackboard the value becomes null. I have tried save/load in BehaviourTree actions and also in C# code. Same result. This does not happen with Graph Blackboard variables.

    I cannot figure out what is going wrong. Seems like a blackboard with one variable of Transform type set to value of a scene gameObject plus myBlackboard.Save() and myBlackboard.Load() should be a no brainer. What am I missing?

    I’m using Unity 2020.3.15f2 and NodeCanvas 3.2.0 on a Mac. Could this be related to this bug issue? / In my case, I have simplified the test to its most basic form (no prefabs, etc) and I am still having issues.

    Not sure if this is at all related to the issue but in trying to chase the issue I noticed that…

    When I save myBlackboard.Save() I get this json back (note “_value”:null ): {"_variables":{"myTransform":{"_value":null,"_name":"myTransform","_id":"837cf83a-55b5-498b-981d-5844ab99bf13","$type":"NodeCanvas.Framework.Variable 1[[UnityEngine.Transform, UnityEngine.CoreModule, Version=, Culture=neutral, PublicKeyToken=null]]"}}}

    When I serialize the blackboard myself myBlackboard.Serialize(storedGoObjectReferences, false), I get nearly identical json except that is “_value”:1:  {"_variables":{"myTransform":{"_value":1,"_name":"myTransform","_id":"837cf83a-55b5-498b-981d-5844ab99bf13","$type":"NodeCanvas.Framework.Variable] 1[[UnityEngine.Transform, UnityEngine.CoreModule, Version=, Culture=neutral, PublicKeyToken=null]]"}}}

    Note: I took out tick mark in the json code above before 1 in NodeCanvas.Framework.Variable] 1 due to interfering with code formatting issues here.

    Thanks for any advice!


    You must be logged in to view attached files.

    Hello there,

    Unfortunately the included Save() and Load() methods are not able to save/load Unity Object references. That is because the Save() and Load() methods save the data to json and then save that json to Unity PlayerPrefs. However, both json only and especially PlayerPrefs are incapable of including the required data for a Unity Object reference. This is why json serialization for Unity Objects always comes in pair with a List(UnityEngine.Object) within which the references are stored. The json, being a string, only holds the index of the reference within that list.

    Is your goal to Save and Load the variables for the current game session, or to Save and Load the variables between gaming sessions (like a Save Game system) ?

    Thank you!

    Join us on Discord:


    Thank you for the clarification. Unity serialization is still a mystery to me so when I read the NodeCanvas documentation that “All the variables of a blackboard are able to save and load” I didn’t connect the dots that Unity Object references would not be possible. (Maybe a one-line note on the Blackboard Save & Load documentation page would be helpful to a future newbie like me?)

    Yes, I am looking to save variables/state between game sessions, and rather than store a vector I wanted to store a game object reference (i.e. a checkpoint) in case I move the checkpoint during prototyping or even game play between sessions.

    I’m not sure if it’s the most elegant solution, or the most performant, but for now I have attached a component to each check point game object that has a persistent GUID, and store a reference to that GUID in the blackboard as a string. On game start, I load the blackboard/saved GUID, find the game object based on that GUID, and use the game object reference from there.


    Hello again,

    No problem and you are right. I did add a note to the documentation section now.

    Your solution of having components with UID string sounds really nice to me 🙂

    Join us on Discord:

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.