On Unity load, Shapes detects SRP then detects URP, causing needless delays

Avatar
  • updated
  • Fixed

Just migrated my URP project from 2019 to 2020.3.17f1 and everything works! But every time I restart Unity, Shapes gets confused. It detects SRP (incorrectly), so it changes all the shaders. Then, soon after, it detects URP (correctly), and changes all the shaders back. 

I'm about to try a fresh install per the sticky post in case that fixes it. But thought it would be good to share in case it doesn't.

Image 511

Image 512

Reporting a bug? please specify Unity version:
2020.3.17f1
Reporting a bug? please specify Shapes version:
4.1
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Spontaneous QuirK

Alas! Clean install didn't help

Avatar
Spontaneous QuirK

Here's the logging sequence...

Shapes updated your project scripting define symbols since you seem to be using the built-in render pipeline, I hope that's okay~
UnityEngine.Debug:Log (object)
Shapes.ShapesImportState:EnsurePreprocessorsAreDefined (Shapes.RenderPipeline) (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:169)
Shapes.ShapesImportState:CheckRenderPipeline () (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:46)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

Shapes failed to load the URP pipeline asset to add the renderer feature. You might have to add ShapesRenderFeature to your renderer asset manually
UnityEngine.Debug:LogWarning (object)
Shapes.ShapesImportState:EnsureShapesPassExistsInTheUrpRenderer () (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:141)
Shapes.ShapesImportState:CheckRenderPipeline () (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:61)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

NullReferenceException: Object reference not set to an instance of an object
Shapes.ShapesImportState.MakeSureSampleMaterialsAreValid () (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:72)
Shapes.ShapesImportState.CheckRenderPipeline () (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:65)
UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at :0)

Shapes updated your project scripting define symbols since you seem to be using URP, I hope that's okay~
UnityEngine.Debug:Log (object)
Shapes.ShapesImportState:EnsurePreprocessorsAreDefined (Shapes.RenderPipeline) (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:169)
Shapes.ShapesImportState:CheckRenderPipeline () (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:46)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

Shapes updated sample material shaders to match your current render pipeline
UnityEngine.Debug:Log (object)
Shapes.ShapesImportState:MakeSureSampleMaterialsAreValid () (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:100)
Shapes.ShapesImportState:CheckRenderPipeline () (at Assets/Shapes/Scripts/Editor/Utils/ShapesImportState.cs:65)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

Avatar
Freya Holmér creator

I really have to do an overhaul over the render pipeline detection system because it's such a messy nightmare to auto-detect this >.>

anything special about your setup? using any experimental packages? URP 2D?

Avatar
Spontaneous QuirK

We are using (after migrating from 2019) URP 10.6 with the standard Render Pipeline Asset pointed at the standard 2D Renderer.

So if that's "special", then yes! :)

When you do overhaul, maybe also provide a way to cancel the auto-fixes, instead of just an "OK" choice.

Until then, any way to disable the auto-detection? Maybe disabling an editor script or specific line somewhere?

While it eventually works, it also confuses Git (suggesting lots of commits to files that didn't really change), so it confuses our team members, and I'd like to avoid all that noise.

Thanks for the quick response!

Avatar
Spontaneous QuirK

Oooh, maybe our "special" problem is that we have a script that dynamically sets our build defines, including SHAPES_URP.

So maybe it's a race condition between that script and your auto-detection script

Avatar
Spontaneous QuirK

In ShapesImportState.cs , here's what I tried to disable the auto-detection, which seems to work

#if UNITY_EDITOR
//[DidReloadScripts( 1 )]
public static void CheckRenderPipelineSoon() => EditorApplication.delayCall += CheckRenderPipeline;

Avatar
Freya Holmér creator
  • Fixed

as of 4.1.1 you can now turn off the auto-config behavior. I've also added a sanity checker section to the shapes settings, as well as a way to force it into a specific render pipeline in case something went wrong somewhere!

Avatar
Spontaneous QuirK
Quote from Freya Holmér

as of 4.1.1 you can now turn off the auto-config behavior. I've also added a sanity checker section to the shapes settings, as well as a way to force it into a specific render pipeline in case something went wrong somewhere!

Very nice. Very nice! 

Thanks so much!