Forums › 💬 NodeCanvas › ⚙️ Support › New Unity dictionary serialization.
Hi @Gavalakis
The current implementation of NodeCanvas’s blackboard serialization seems to conflict with Unity’s upcoming dictionary serialization, which will ship with 6.6.
I understand Unity 6.6 is still in Beta and not are not supporting it yet, just wondering if this is on your radar and if you have an idea of how much effort it will be to support it (i.e. minor changes vs significant refactor of NodeCanvas’s serialization code).
Thanks!
Hello!
Thank you for letting me know! I wasn’t aware of it actually and don’t know what the conflict is right now, but I will of course take a look it ASAP after summer vacation. Hopefully it will not be something major!
Thanks!
Hey, I went over the NodeCanvas code and realized it’s actually doing fully custom serialization for blackboards and graphs, so this shouldn’t be an issue at all. Supressing the compiler error with pragmas should suffice.
On .\ParadoxNotion\CanvasCore\Framework\Runtime\Variables\Internal\BlackboardSource.cs, line 13:
|
1 2 3 4 5 |
#pragma warning disable UAC1012 [SerializeField] private Dictionary<string, Variable> _variables = new Dictionary<string, Variable>(StringComparer.Ordinal); #pragma warning restore UAC1012 |
It was already disabling UAC1009 anyway (even though that was just a warning, not an actual error).
Hey, thanks for letting me know! Yes, NodeCanvas uses custom serialization 🙂
Hi,
There is something wrong going on with this attribute in the BlackboardSource class.
|
1 2 |
[ParadoxNotion.Serialization.FullSerializer.fsSerializeAs] private Dictionary<string, Variable> _variables = new Dictionary<string, Variable>(StringComparer.Ordinal); |
From what I checked when updating my old NC version to work with Unity 6.6, it used to be [SerializeField] there, but as far as I understand, this attribute did nothing at all, as Dictionary serialization wasn’t supported. Now in 6.6 (6000.6.0f1) they made [SerializeField] explicitly show up as an error.
So after updating to 3.42, I have this problem when [ParadoxNotion.Serialization.FullSerializer.fsSerializeAs] is present. When I open a prefab that has FSM Owner and Blackboard components, the blackboard doesn’t load properly and my console is spammed with
|
1 2 3 4 |
NullReferenceException: Object reference not set to an instance of an object NodeCanvas.Framework.Blackboard.SelfSerialize () (at Assets/Plugins/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/Blackboard.cs:57) NodeCanvas.Framework.Blackboard.UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize () (at Assets/Plugins/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/Blackboard.cs:36) UnityEditor.GUIView:ProcessEvent(EntityId, IntPtr, Boolean&) |
Pointing to this line:
if ( newSerialization != _serializedBlackboard || !newReferences.SequenceEqual(_objectReferences) || ( _serializedVariables == null || _serializedVariables.Length != _blackboard.variables.Count ) )
From my understanding, _blackboard.variables here is null.
Interestingly, if I remove this attribute entirely, this prefab works perfectly. However, another problem happens instead. Now without this attribute, other objects, even prefab instances, where I have FSM Owner components that don’t have a blackboard attached as a component, only the blackboard inside the graph, can’t load their blackboard variables.
(Execution Error): A Parameter Variable named 'cooldown' is missing. If it was meant to be a dynamic variable, please ensure that it starts with an underscore ('_') prefix by convention.
Hello,
Just to clarify, [SerializeField] did something; it was serializing the blackboard, but through FullSerializer (which is the custom serializer used in NodeCanvas). The change to [fsSerializeAs] has practically no difference at all, because both [SerializeField] and [fsSerializeAs] do exactly the same thing as far as FullSerialize handles them.
Do no remove the attribute. It is required to serialize the blackboard.
I have tried opening old projects and everything works as expected (there is honestly no reason not to since both attributes do the exact same thing Full Serializer wise). Could it be that your get the errors because you removed the attribute first and then re-added?
Let me know. Thanks.
Hey, thanks for the clarification! Restarting and re-importing a few times seems to have solved it.
