ShaderGraphVariables icon indicating copy to clipboard operation
ShaderGraphVariables copied to clipboard

`ArgumentNullException : Value cannot be null` error with a specific graph - unity 2022.3.14

Open NeistH2o opened this issue 1 year ago • 0 comments

For some reason I can't explain, I get an exception when one of my graphs is open, I recently updated from v1.0.0 to v1.0.5 .

The problem with this error is that the graph becomes impossible to edit, as Unity throws NullReferenceExceptions when I try to move a node, create or delete one, or anything else.

I copied the exception I'm getting below but what is happening seems to be that an edge that links two node seems to have its node variable set to null, and unity fails to recover from there. At least that's what I understood, but I failed to prevent this from happening, and I don't know exactly what is the root cause, as other graphs seem to work without problem.

The only way I found to get back control over the graph was to add return null; at the very beginning of the Connect(Port a, Port b, bool noValidate = false) method in SGVariables.cs.

I can't share the shadergraph file here but let me know if you want me to send it to you in some other way.

Errors (collapsed)
ArgumentNullException: Value cannot be null.
Parameter name: identifier
UnityEditor.Undo.RegisterCompleteObjectUndo (UnityEngine.Object objectToUndo, System.String name) (at <ac8a1d1a125546cf82b0ec17802fc7c2>:0)
UnityEditor.Graphing.GraphObject.RegisterCompleteObjectUndo (System.String actionName) (at ./Library/PackageCache/[email protected]/Editor/Data/Implementation/GraphObject.cs:113)
UnityEditor.ShaderGraph.Drawing.GraphEditorView.GraphViewChanged (UnityEditor.Experimental.GraphView.GraphViewChange graphViewChange) (at ./Library/PackageCache/[email protected]/Editor/Drawing/Views/GraphEditorView.cs:488)
UnityEditor.Experimental.GraphView.SelectionDragger.OnMouseUp (UnityEngine.UIElements.MouseUpEvent evt) (at <9bf8e89a4e1c457c8a246151ea3730b4>:0)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.PropagationPhase propagationPhase) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.PropagationPhase propagationPhase) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <545885fff981424ba24fbd84a445d137>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <cffc46fa8b1e4ee1a0e1b35a8d998061>:0)

and/or

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.ShaderGraph.Drawing.GraphEditorView.HandleGraphChanges (System.Boolean wasUndoRedoPerformed) (at ./Library/PackageCache/[email protected]/Editor/Drawing/Views/GraphEditorView.cs:814)
UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow.Update () (at ./Library/PackageCache/[email protected]/Editor/Drawing/MaterialGraphEditWindow.cs:372)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.ShaderGraph.Drawing.GraphEditorView.HandleGraphChanges (System.Boolean wasUndoRedoPerformed) (at ./Library/PackageCache/[email protected]/Editor/Drawing/Views/GraphEditorView.cs:814)
UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow.Update () (at ./Library/PackageCache/[email protected]/Editor/Drawing/MaterialGraphEditWindow.cs:384)
UnityEditor.HostView.SendUpdate () (at <ac8a1d1a125546cf82b0ec17802fc7c2>:0)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <ac8a1d1a125546cf82b0ec17802fc7c2>:0)

NeistH2o avatar May 15 '24 16:05 NeistH2o