diff --git a/Source/AssetRipper.Export.UnityProjects/Shaders/USCShaderExporter.cs b/Source/AssetRipper.Export.UnityProjects/Shaders/USCShaderExporter.cs index a4e0e63e89..dd6b609ca6 100644 --- a/Source/AssetRipper.Export.UnityProjects/Shaders/USCShaderExporter.cs +++ b/Source/AssetRipper.Export.UnityProjects/Shaders/USCShaderExporter.cs @@ -12,6 +12,7 @@ using AssetRipper.Export.Modules.Shaders.UltraShaderConverter.UShader.DirectX; using AssetRipper.Export.Modules.Shaders.UltraShaderConverter.USIL; using AssetRipper.Export.UnityProjects.Configuration; +using AssetRipper.Import.Logging; using AssetRipper.IO.Files; using AssetRipper.SourceGenerated.Classes.ClassID_48; using AssetRipper.SourceGenerated.Extensions; @@ -34,8 +35,18 @@ public sealed class USCShaderExporter : ShaderExporterBase public override bool Export(IExportContainer container, IUnityObjectBase asset, string path) { using Stream fileStream = File.Create(path); - ExportBinary((IShader)asset, fileStream, ShaderExporterInstantiator); - return true; + try + { + ExportBinary((IShader)asset, fileStream, ShaderExporterInstantiator); + return true; + } + catch (Exception ex) + { + Logger.Error(ex); + fileStream.Position = 0; + DummyShaderTextExporter.ExportShader((IShader)asset, new InvariantStreamWriter(fileStream)); + return false; + } } private static ShaderTextExporter ShaderExporterInstantiator(GPUPlatform graphicApi) @@ -80,7 +91,7 @@ private static void ExportBinary(IShader shader, Stream stream, Func"; + string header = shader.Script.String; if (writer.Blobs.Length == 0) { writer.Write(header); @@ -93,7 +104,7 @@ private static void ExportBinary(IShader shader, Stream stream, Func"); + writer.Write(shader.Script.String); } }