From 385ff04b88da7e7624497d3aa6152f1a467be00d Mon Sep 17 00:00:00 2001 From: Philip Johansson Date: Thu, 18 Jun 2026 14:03:37 +0200 Subject: [PATCH] Fix import error for default material This error appears during initial import in the AssetPostprocessorHandler.OnPostprocessPrefab callback, which runs during asset import. Shader.Find() attempts to find the CrossRPDefault shader which is not yet loaded. This causes the Material constructor to throw an ArgumentNullException. This is a non-issue past the first import so this fix it merely to suppress the error --- AGXUnity/Utils/RenderingUtils.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/AGXUnity/Utils/RenderingUtils.cs b/AGXUnity/Utils/RenderingUtils.cs index aa7a97f2..e4983ede 100644 --- a/AGXUnity/Utils/RenderingUtils.cs +++ b/AGXUnity/Utils/RenderingUtils.cs @@ -126,7 +126,18 @@ public static bool CameraShouldRender( Camera cam, GameObject allowedPrefabObjec /// A new material if the current render pipeline is recognized or null otherwise public static Material CreateDefaultMaterial() { - return new Material( Shader.Find( "AGXUnity/Shader Graph/CrossRPDefault" ) ); + var shader = Shader.Find( "AGXUnity/Shader Graph/CrossRPDefault" ); + if ( shader == null ) + { + Debug.LogWarning( "AGXUnity/Shader Graph/CrossRPDefault shader not found. Falling back to Standard shader." ); + shader = Shader.Find( "Standard" ); + } + if ( shader == null ) + { + Debug.LogError( "Failed to find any suitable shader for CreateDefaultMaterial." ); + return null; + } + return new Material( shader ); } ///