Forums › 💬 NodeCanvas › ⚙️ Support › 2018.3 upgrade issues
We’re using a bit older version of nodecanvas for some of our game scripting with Unity 2018.2.19f1 .. I tried to upgrade to Unity 2018.3 because there’s a unity editor crash we’re getting that they tell us they’ve fixed in 2018.3.2f1, but there are issues with our graph serialization
The validate() call is just looping over and over iirc because the highlighted code is failing. I believe it returns null. I downloaded the very latest nodecanvas to see if there was an easy fix but it looks like a lot of the serialization has changed and it’s not obvious how I would fix it. Short of doing a very painful upgrade of the nodecanvas framework, can you suggest how this should be rewritten? Thanks
Hello,
You could replace the Validate method with the code found in the Validate method in the latest version, which handles whether or not we are under Unity 2018.3. Here is the code for your convenience:
|
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 |
public void Validate() { //everything here is relevant to bound graphs only if ( graphIsBound && !Application.isPlaying && !UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode ) { #if !UNITY_2018_3_OR_NEWER //works in 2018.3 without this code var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this); if ( prefabType == UnityEditor.PrefabType.Prefab ) { //Update from previous version. No longer store graph as sub-asset. if ( graph != null && UnityEditor.AssetDatabase.IsSubAsset(graph) ) { DestroyImmediate(graph, true); } } #endif if ( boundGraphInstance == null ) { boundGraphInstance = (Graph)ScriptableObject.CreateInstance(graphType); } #if !UNITY_2018_3_OR_NEWER //works in 2018.3 without this code boundGraphInstance.hideFlags = prefabType == UnityEditor.PrefabType.Prefab ? HideFlags.HideAndDontSave : HideFlags.None; #endif boundGraphInstance.Deserialize(boundGraphSerialization, false, boundGraphObjectReferences); ( boundGraphInstance as UnityEngine.Object ).name = this.name + " " + graphType.Name; boundGraphInstance.UpdateReferencesFromOwner(this); boundGraphInstance.Validate(); boundGraphSerialization = boundGraphInstance.Serialize(false, boundGraphObjectReferences); graph = boundGraphInstance; } } |
Let me know if that works for you.
Thanks.
I had compared that code and it looked a lot different.. but if it is that simple, that is fantastic.. thanks 🙂 I’ll give it a try
Finally had a chance to upgrade to 2018.3 .. This was all that was needed. Thanks for your help
|
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 |
public void Validate(){ //everything bellow is relevant to bound graphs only if (!graphIsBound || Application.isPlaying || UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode){ return; } var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this); if (boundGraphInstance == null){ #if !UNITY_2018_3_OR_NEWER if (prefabType == UnityEditor.PrefabType.Prefab){ if (graph == null){ graph = (Graph)ScriptableObject.CreateInstance(graphType); UnityEditor.AssetDatabase.AddObjectToAsset(graph, this); string path = UnityEditor.AssetDatabase.GetAssetPath(graph); if ( !string.IsNullOrEmpty( path ) ) { UnityEditor.EditorApplication.delayCall += ()=>{ UnityEditor.AssetDatabase.ImportAsset( path ); }; } } boundGraphInstance = graph; } else { boundGraphInstance = (Graph)ScriptableObject.CreateInstance(graphType); } #else boundGraphInstance = (Graph)ScriptableObject.CreateInstance(graphType); #endif } boundGraphInstance.Deserialize(boundGraphSerialization, false, boundGraphObjectReferences); #if !UNITY_2018_3_OR_NEWER boundGraphInstance.hideFlags = HideFlags.None; #endif (boundGraphInstance as UnityEngine.Object).name = this.name + " " + graphType.Name; boundGraphInstance.Validate(); graph = boundGraphInstance; boundGraphSerialization = graph.Serialize(false, boundGraphObjectReferences); graph.agent = this; graph.blackboard = this.blackboard; } |
