NodeCanvas Forums › Support › [BUG] Graph breaking bug.
This happens on latest NodeCanvas patch ( v3.0.8). Graph stops working completely, GUI doesnt show any nodes and runtime errors. New clean graphs still work.
HOW TO REPRODUCE:
Add connection with condition shown below. Let Unity compile and BOOM!
I was working with code that has to do with NavMeshPath and when i added NavMeshPath to my local BB graph this started to happen.
Here is the code i was working on and below are the errors too.
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 |
namespace NodeCanvas.Tasks.Actions{ [Category("NavMesh")] public class CalculatePath : ConditionTask<NavMeshAgent> { public BBParameter<Vector3> destination; public BBParameter<NavMeshPath> savePathAs; public BBParameter<List<Vector3>> saveCornersAs; protected override bool OnCheck() { NavMeshPath path = new NavMeshPath(); agent.CalculatePath(destination.value, path); if(path.status == NavMeshPathStatus.PathComplete) { savePathAs.value = path; saveCornersAs.value.Clear(); saveCornersAs.value.AddRange(path.corners); return true; } return false; } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
NullReferenceException: Object reference not set to an instance of an object NodeCanvas.Framework.Node.get_isHidden () (at Assets/ParadoxNotion/CanvasCore/Framework/Design/PartialEditor/Editor.Node.cs:112) NodeCanvas.Framework.Node.ShowNodeGUI (NodeCanvas.Framework.Node node, UnityEngine.Rect drawCanvas, System.Boolean fullDrawPass, UnityEngine.Vector2 canvasMousePos, System.Single zoomFactor) (at Assets/ParadoxNotion/CanvasCore/Framework/Design/PartialEditor/Editor.Node.cs:254) NodeCanvas.Editor.GraphEditor.ShowNodesGUI (NodeCanvas.Framework.Graph graph, UnityEngine.Rect drawCanvas, System.Boolean fullDrawPass, UnityEngine.Vector2 canvasMousePos, System.Single zoomFactor) (at Assets/ParadoxNotion/CanvasCore/Framework/Design/Editor/Windows/GraphEditor.cs:659) NodeCanvas.Editor.GraphEditor.OnGUI () (at Assets/ParadoxNotion/CanvasCore/Framework/Design/Editor/Windows/GraphEditor.cs:504) System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <480b5a3bd3214ce5831f6dd8c68fdc55>:0) UnityEditor.HostView.Invoke (System.String methodName) (at <480b5a3bd3214ce5831f6dd8c68fdc55>:0) UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <480b5a3bd3214ce5831f6dd8c68fdc55>:0) UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <480b5a3bd3214ce5831f6dd8c68fdc55>:0) UnityEditor.DockArea.OldOnGUI () (at <480b5a3bd3214ce5831f6dd8c68fdc55>:0) UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <95b42489e2e04430a87c3760aa29fca2>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) |
1 2 |
GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) |
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 |
UnityException: InitializeNavMeshPath is not allowed to be called during serialization, call it from OnEnable instead. Called from ScriptableObject 'FSM'. See "Script Serialization" page in the Unity Manual for further details. UnityEngine.AI.NavMeshPath..ctor () (at <030353032b914045a0b96bea329b98d3>:0) System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0) System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) (at <437ba245d8404784b9fbab9b439ac908>:0) System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <437ba245d8404784b9fbab9b439ac908>:0) System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <437ba245d8404784b9fbab9b439ac908>:0) System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) (at <437ba245d8404784b9fbab9b439ac908>:0) ParadoxNotion.Serialization.FullSerializer.fsMetaType+<>c__DisplayClass21_0.<GetGenerator>b__5 () (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsMetaType.cs:147) ParadoxNotion.Serialization.FullSerializer.fsMetaType.CreateInstance () (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsMetaType.cs:179) ParadoxNotion.Serialization.FullSerializer.Internal.fsReflectedConverter.CreateInstance (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/Converters/fsReflectedConverter.cs:111) ParadoxNotion.Serialization.FullSerializer.fsSerializer.Internal_Deserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:557) ParadoxNotion.Serialization.FullSerializer.fsSerializer.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:484) ParadoxNotion.Serialization.FullSerializer.Internal.fsReflectedConverter.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Object& instance, System.Type storageType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/Converters/fsReflectedConverter.cs:98) ParadoxNotion.Serialization.FullSerializer.fsSerializer.Internal_Deserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:589) ParadoxNotion.Serialization.FullSerializer.fsSerializer.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:484) ParadoxNotion.Serialization.FullSerializer.fsSerializer.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:468) ParadoxNotion.Serialization.FullSerializer.Internal.fsDictionaryConverter.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Object& instance_, System.Type storageType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/Converters/fsDictionaryConverter.cs:101) ParadoxNotion.Serialization.FullSerializer.fsSerializer.Internal_Deserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:589) ParadoxNotion.Serialization.FullSerializer.fsSerializer.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:484) ParadoxNotion.Serialization.FullSerializer.Internal.fsReflectedConverter.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Object& instance, System.Type storageType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/Converters/fsReflectedConverter.cs:98) ParadoxNotion.Serialization.FullSerializer.fsSerializer.Internal_Deserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:589) ParadoxNotion.Serialization.FullSerializer.fsSerializer.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:484) ParadoxNotion.Serialization.FullSerializer.Internal.fsReflectedConverter.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Object& instance, System.Type storageType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/Converters/fsReflectedConverter.cs:98) ParadoxNotion.Serialization.FullSerializer.fsSerializer.Internal_Deserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:589) ParadoxNotion.Serialization.FullSerializer.fsSerializer.TryDeserialize (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Type overrideConverterType) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:484) ParadoxNotion.Serialization.JSONSerializer.Internal_Deserialize (System.Type type, System.String json, System.Collections.Generic.List |
1[T] references, System.Object instance) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/JSONSerializer.cs:111)
ParadoxNotion.Serialization.JSONSerializer.TryDeserializeOverwrite[T] (T instance, System.String json, System.Collections.Generic.List1[T] references) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/JSONSerializer.cs:80)
1[T] references, System.Boolean validate) (at Assets/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:150)
NodeCanvas.Framework.Graph.Deserialize (System.String serializedGraph, System.Collections.Generic.List
UnityEngine.Logger:LogException(Exception)
ParadoxNotion.Services.Logger:ForwardToUnity(LogType, Object, String, Object) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Services/Logger.cs:114)
ParadoxNotion.Services.Logger:Internal_Log(LogType, Object, String, Object) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Services/Logger.cs:108)
ParadoxNotion.Services.Logger:LogException(Exception, String, Object) (at Assets/ParadoxNotion/CanvasCore/Common/Runtime/Services/Logger.cs:66)
NodeCanvas.Framework.Graph:Deserialize(String, List1, Boolean) (at Assets/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:166)
NodeCanvas.Framework.Graph:SelfDeserialize() (at Assets/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:111)
NodeCanvas.Framework.Graph:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at Assets/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:48)
I think you’re not supposed to use non-serializable types as BBParameter variables. This happens because NC tries to create a NavMeshPath instance when it loads the graph and unity doesn’t allow that (similarly to how you can’t access some other APIs during certain points like serialization or construction). I guess you’re trying to have one action generate the path where you can store it and then re-use it in some other action to apply it. But I’m unfortunately not having an idea how this could be solved properly. I guess something in the underlying serialization logic must be changed so it does not try to persist NavMeshPath instances anywhere.
Hey,
It seems that the constructor of NavMeshPath apparently has code that can’t run OnAfterDeserialize. I have modified the instance generation so that it try/catches any exceptions (such as this) when constructing an object and attached the changed for you here.
This will at least prevent the NavMeshPath (or other object construction that throws an exception) from being constructed if not able, but won’t go boom on the rest of the graph.
Join us on Discord: https://discord.gg/97q2Rjh
That seemed to do the trick! Thanks for help you all.