Overridden OnValidate() causes MissingException Error

NodeCanvas Forums Support Overridden OnValidate() causes MissingException Error

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13066
    11tomi12
    Participant

    Hi.

    I implemented localized Say and MultiChoices nodes, which worked more or less fine.
    After I updated NodeCanvas version, I started getting an error, which happened, when public override void OnValidate(Graph assignedGraph) is called.

    I used this method for duplication purposes, to transfer some data to the new node. After I updated your plugin, it doesn’t work anymore and I get this error.
    (Also, a very frustrating bug I have is that pressing spacebar while typing in EditorGUILayout.TextArea causes the search nodes menu to open. Nothing I tried fixed this issue. I mentioned it because I already saw another post in this month mentioning the same issue.)

    If it helps, here is the code from the localized MultiChoice node: https://codeshare.io/29QjO4

    Exception message for the first problem:

    MissingReferenceException: The object of type ‘MonoManager’ has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.MonoBehaviour.StartCoroutine (IEnumerator routine) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/MonoBehaviourBindings.gen.cs:62)
    NodeCanvas.Framework.Node.StartCoroutine (IEnumerator routine) (at Assets/ParadoxNotion/NodeCanvas/Framework/Runtime/Graphs/Node.cs:444)
    NodeCanvas.DialogueTrees.LocalizedMultipleChoiceNode.OnValidate (NodeCanvas.Framework.Graph assignedGraph) (at Assets/NodeCanvas-I2Localization-master/unity-project/Assets/NodeCanvas Integrations/I2 Localization/Tasks/Actions/Dialogue/LocalizedMultipleChoiceNode.cs:203)
    NodeCanvas.Framework.Node.Duplicate (NodeCanvas.Framework.Graph targetGraph) (at Assets/ParadoxNotion/NodeCanvas/Framework/Runtime/Graphs/Node.cs:241)
    NodeCanvas.Editor.GraphEditor.HandlePostNodesGraphEvents (NodeCanvas.Framework.Graph graph, Vector2 canvasMousePos) (at Assets/ParadoxNotion/NodeCanvas/Framework/Design/Editor/Windows/GraphEditor_Events.cs:127)
    NodeCanvas.Editor.GraphEditor.OnGUI () (at Assets/ParadoxNotion/NodeCanvas/Framework/Design/Editor/Windows/GraphEditor.cs:528)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:295)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:288)
    UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:255)

    EDIT: Found another bug, not sure if caused by my added code or not: Whenever I open search nodes menu(by right click usually), I get this error: “InvalidCastException: Cannot cast from source type to destination type.
    UnityEditor.EditorGUILayout.BeginScrollView (Vector2 scrollPosition, Boolean alwaysShowHorizontal, Boolean alwaysShowVertical, UnityEngine.GUIStyle horizontalScrollbar, UnityEngine.GUIStyle verticalScrollbar, UnityEngine.GUIStyle background, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7957)

    #13075
    Gavalakis
    Keymaster

    Hello and sorry for the late reply (I was ill).

    For the spacebar bug, please refer to this forum thread where I have posted the fix file at the end. [LINK].

    Regarding the OnValidate issue you are having, it looks like you are calling StartCoroutine in Editor Mode (when duplicating node), while StartCoroutine should only be used and will work correctly in Play Mode. This is also why MonoManager which is responsible for running coroutines is null at that time (since once again coroutines are for play mode).
    This shouldn’t be working even on the previous version of NC to be honest 🙂

    Why not simply serialize the data you want the node to have into some fields? When duplicating, these will be copied over.

    Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

    #13085
    11tomi12
    Participant

    Hello and thank you for your reply!

    First of all thanks for the spacebar bug solution.
    About Coroutines: I honestly didn’t realize they only work in play mode. I removed them and made a simple fix. I used them in first place because when OnValidate was called, node ID was 0, which caused problem with my implemented ID generation.

    I still have one bug, that occurs when opening search window for nodes:
    InvalidCastException: Cannot cast from source type to destination type.
    UnityEditor.EditorGUILayout.BeginScrollView (Vector2 scrollPosition, Boolean alwaysShowHorizontal, Boolean alwaysShowVertical, UnityEngine.GUIStyle horizontalScrollbar, UnityEngine.GUIStyle verticalScrollbar, UnityEngine.GUIStyle background, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7957)

    Origin is class GenericMenuBrowser.cs line 345. This error occurs even if no nodes are in graph.

    #13123
    Gavalakis
    Keymaster

    Hello and sorry for late reply once again.
    You are very welcome and I am glad I could help 🙂
    Indeed I encounter this error myself only recently as well and I am already trying to resolve it. I still can’t really find the cause of this and I think that it is a Unity bug rather than a NodeCanvas bug, since it only appears to take place in 2017+, as well as due to the fact that the null reference exception points to a Unity method directly. I will investigate a bit further, but know that the error is harmless (even though certainly annoying and should be resolved) 🙂

    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

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