Cyanilux / ShaderGraphVariables

Adds 'Register Variable' and 'Get Variable' nodes to Shader Graph, allowing you to link sections of a graph without connection wires. <3
MIT License
262 stars 24 forks source link

Updating from 1.0.5 to 1.0.6 breaks some graphs #12

Open fleity opened 3 days ago

fleity commented 3 days ago

I have a hard time pinpointing why exactly some graphs break and some not but when I update to the latest version (Vector 2/3 fix). Some nodes (presumably GetVariable getting vector2) breaks the entire graph, making it unable to be edited. When moving a node it sticks to the mouse and can not be dropped.

I guess the issue has to do with GetVariable Vector4 output being connected to a swizzle xy. This connection changes color between the two package versions and therefore seem to change connection type. Maybe that is something the swizzle has trouble handling (encountered that a few times before with Vector4 to float and vice versa conversions when using this package).

There are 3 errors:

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.ShaderGraph.Drawing.GraphEditorView.HandleGraphChanges (System.Boolean wasUndoRedoPerformed) (at Library/PackageCache/com.unity.shadergraph@14.0.11/Editor/Drawing/Views/GraphEditorView.cs:814)
UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow.Update () (at Library/PackageCache/com.unity.shadergraph@14.0.11/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/com.unity.shadergraph@14.0.11/Editor/Drawing/Views/GraphEditorView.cs:814)
UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow.Update () (at Library/PackageCache/com.unity.shadergraph@14.0.11/Editor/Drawing/MaterialGraphEditWindow.cs:384)
UnityEditor.HostView.SendUpdate () (at <477bdcb097d4488eae58cbed17286dd8>:0)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <477bdcb097d4488eae58cbed17286dd8>:0)
ArgumentNullException: Value cannot be null.
Parameter name: identifier
UnityEditor.Undo.RegisterCompleteObjectUndo (UnityEngine.Object objectToUndo, System.String name) (at <477bdcb097d4488eae58cbed17286dd8>:0)
UnityEditor.Graphing.GraphObject.RegisterCompleteObjectUndo (System.String actionName) (at Library/PackageCache/com.unity.shadergraph@14.0.11/Editor/Data/Implementation/GraphObject.cs:113)
UnityEditor.ShaderGraph.Drawing.MaterialNodeView.SetPreviewExpandedStateOnSelection (System.Boolean state) (at Library/PackageCache/com.unity.shadergraph@14.0.11/Editor/Drawing/Views/MaterialNodeView.cs:474)
UnityEditor.ShaderGraph.Drawing.MaterialNodeView.<Initialize>b__14_3 () (at Library/PackageCache/com.unity.shadergraph@14.0.11/Editor/Drawing/Views/MaterialNodeView.cs:137)
UnityEngine.UIElements.Clickable.Invoke (UnityEngine.UIElements.EventBase evt) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.Clickable.ProcessUpEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.Vector2 localPosition, System.Int32 pointerId) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.Clickable.OnMouseUp (UnityEngine.UIElements.MouseUpEvent evt) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.PropagationPhase propagationPhase) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.PropagationPhase propagationPhase) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <fef112fd0f15457e8e58500118cb5cea>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <701a05767aa048528876500a22329b6c>:0)

image image

Cyanilux commented 2 days ago

Seems a duplicate of #11 I've been looking into it but also having a hard time debugging.

As far as I can tell, it's specific to 2022.x versions... (specifically 2022.3.21f1 is the version I have installed). I've tested in 2020.3 and 2023.1 and there's no errors there.

I don't think it's related to the Swizzle here, or the new Vector2/3 types. As mentioned in that other issue it's something with the Connect/ConnectReflection method, as returning early prevents the errors (but means the tool stops working). But I haven't been able to find a fix yet 😢