I have recently started getting a null reference exception error when trying to add nodes to shader graph.
NullReferenceException: Object reference not set to an instance of an object UnityEditor.ShaderGraph.Drawing.SearchWindowProvider.GenerateNodeEntries () (at ./Library/PackageCache/com.unity.shadergraph@14.0.5/Editor/Drawing/SearchWindowProvider.cs:79)
This is consistently occurring when trying to use the space bar shortcut and regularly occurring when using right click > create node. Sometimes restarting shader graph or unity seems to temporarily resolve the issue.
I’ve not touched Shader Graph package code. Is this a bug?
I have this issue as well on 14.04. Not sure what causes it. I can close and then reopen the graph, but the bug always comes back, making Shader Graph nearly unusable.
Yes, I’m finding that it is specifically exiting play mode that seems to trigger the issue. I can edit the graph during play mode but as soon as I exit play mode I consistently get the null reference exception.
I get this a lot in 2022.2.8f1 as well (I think it started in 2022.2.5f1)
It’s not a 100% repro, and seems to relate to which objects are selected.
Workaround is to close and reopen the graph, one or two steps of work as well as the view positon will be lost even if you save on closing, which makes this quite jarring.
I tried to fiddle with searcher features, but to no avail. They seem to be unrelated, despite the name. So some more defensive programming here would be much appreciated, a single activeTarget that becomes null must never soft-lock the user out of any meaningful interaction with the entirety of ShaderGraph.
I’m considering working around the issue by adding some exception handling to the crashing code, but rolling custom RP package is always a hassle.
Edit: In fact, the patch would be in the ShaderGraph package, but I can’t turn that into a custom package for some magical reason (totally breaks all shadergraphs, won’t reimport). Would be offtopic, but moving this to Packages from Package Cache doesn’t work, which is weird. Aren’t packages supposed to be, you know, like packages?
Edit2: Had to reimport all shadergraphs that were DefaultAssets now for some reason, then reimport all custom subgraphs from another package, and then all of my shadergraphs again.