FlowCanvas Forums › Support › 2018.3 Prefabs › Reply To: 2018.3 Prefabs
Update
Today I implemented flow canvas in another existing project and reworked my objects into prefab variants with flow canvas controllers and everything went as expected no errors. So whatever I’m doing with the custom task must just be throwing a wrench in the whole thing.
I went back to the project I submitted earlier and did some more testing. If you unpack the prefab completely it will run, I even filled out some flow scripts and everything was fine.
The moment I set it up as a prefab I start getting errors so I think there’s some issues with the serialization of node canvas I’m triggering somehow but flow canvas does seem to be up and running in 2018.3 =D
I did however notice that the way blackboard variables work ( forgive me if I’m misunderstanding what’s happening ) are not compatible with prefab variant workflows since they’re stored as a single string which explains some of my confusion about data loss there. I might suggest storing them as individual json parts during edit and creating a final serialized string separately to use at runtime. This would be a great addition! In the mean time I’m going to try my hand at extending the blackboard to support this.
I managed to hack it in =P
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | [SerializeField] private List<string> _serializedVariables = new List<string>(); //serialize blackboard variables to json void ISerializationCallbackReceiver.OnBeforeSerialize() { #if UNITY_EDITOR if (JSONSerializer.applicationPlaying) { return; } if (_objectReferences != null && _objectReferences.Count > 0 && _objectReferences.Any(o => o != null)) { hasDeserialized = false; } _objectReferences = new List<UnityEngine.Object>(); _serializedBlackboard = JSONSerializer.Serialize(typeof(BlackboardSource), _blackboard, false, _objectReferences); var data = fsJsonParser.Parse(_serializedBlackboard); var variables = data.AsDictionary["_variables"].AsDictionary; _serializedVariables.Clear(); foreach (var item in variables) { _serializedVariables.Add("\"" + item.Key + "\": " + item.Value); } #endif } //deserialize blackboard variables from json void ISerializationCallbackReceiver.OnAfterDeserialize() { if (hasDeserialized && JSONSerializer.applicationPlaying) { return; } hasDeserialized = true; #if UNITY_EDITOR if (!JSONSerializer.applicationPlaying) { var json = "{\"_variables\":{"; for (int i = 0; i < _serializedVariables.Count; i++) { var item = _serializedVariables[i]; json += item; if (i != _serializedVariables.Count - 1) { json += ","; } } json += "}}"; _blackboard = JSONSerializer.Deserialize<BlackboardSource>(json, _objectReferences); } else { _blackboard = JSONSerializer.Deserialize<BlackboardSource>(_serializedBlackboard, _objectReferences); } #else _blackboard = JSONSerializer.Deserialize<BlackboardSource>(_serializedBlackboard, _objectReferences); #endif if (_blackboard == null) _blackboard = new BlackboardSource(); } |