diff --git a/Packages/com.unity.render-pipelines.core/Editor/UnifiedRayTracing/UnifiedRTShaderImporter.cs b/Packages/com.unity.render-pipelines.core/Editor/UnifiedRayTracing/UnifiedRTShaderImporter.cs index 7c82be5e528..116a2125d89 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/UnifiedRayTracing/UnifiedRTShaderImporter.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/UnifiedRayTracing/UnifiedRTShaderImporter.cs @@ -8,7 +8,11 @@ internal class UnifiedRTShaderImporter : ScriptedImporter { public override void OnImportAsset(AssetImportContext ctx) { +#if UNITY_6000_5_OR_NEWER + string source = File.ReadAllText(FileUtil.PathToAbsolutePath(ctx.assetPath)); +#else string source = File.ReadAllText(ctx.assetPath); +#endif var com = ShaderUtil.CreateComputeShaderAsset(ctx, computeShaderTemplate.Replace("SHADERCODE", source)); var rt = ShaderUtil.CreateRayTracingShaderAsset(ctx, diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Processors/Generator.cs b/Packages/com.unity.shadergraph/Editor/Generation/Processors/Generator.cs index 06afc60c5ce..22af3e159eb 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Processors/Generator.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Processors/Generator.cs @@ -1241,7 +1241,7 @@ void ProcessStackForPass(ContextData contextData, BlockFieldDescriptor[] passBlo // Shared Templates string[] sharedTemplateDirectories = pass.sharedTemplateDirectories; - if (!File.Exists(passTemplatePath)) + if (!File.Exists(FileUtilities.PathToAbsolutePath(passTemplatePath))) { UnityEngine.Profiling.Profiler.EndSample(); // GenerateShaderPass return; diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Processors/ShaderSpliceUtil.cs b/Packages/com.unity.shadergraph/Editor/Generation/Processors/ShaderSpliceUtil.cs index e193eb18680..065c80f297c 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Processors/ShaderSpliceUtil.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Processors/ShaderSpliceUtil.cs @@ -238,7 +238,7 @@ private void ProcessIncludeCommand(Token includeCommand, int lineEnd) string templatePath = templatePaths[i]; includeLocation = Path.Combine(templatePath, param.GetString()); bool cacheHit = includeCache.ContainsKey(includeLocation); - if (cacheHit || File.Exists(includeLocation)) { + if (cacheHit || File.Exists(FileUtilities.PathToAbsolutePath(includeLocation))) { found = true; break; } diff --git a/Packages/com.unity.shadergraph/Editor/Util/FileUtilities.cs b/Packages/com.unity.shadergraph/Editor/Util/FileUtilities.cs index 545f9764679..b667636180b 100644 --- a/Packages/com.unity.shadergraph/Editor/Util/FileUtilities.cs +++ b/Packages/com.unity.shadergraph/Editor/Util/FileUtilities.cs @@ -37,7 +37,7 @@ public static bool WriteToDisk(string path, string text) { try { - File.WriteAllText(path, text); + File.WriteAllText(PathToAbsolutePath(path), text); } catch (Exception e) { @@ -74,7 +74,7 @@ public static string SafeReadAllText(string assetPath) string result = null; try { - result = File.ReadAllText(assetPath, Encoding.UTF8); + result = File.ReadAllText(PathToAbsolutePath(assetPath), Encoding.UTF8); } catch { @@ -83,11 +83,20 @@ public static string SafeReadAllText(string assetPath) return result; } + public static string PathToAbsolutePath(string path) + { +#if UNITY_6000_5_OR_NEWER + return FileUtil.PathToAbsolutePath(path); +#else + return Path.GetFullPath(path); +#endif + } + internal static bool TryReadGraphDataFromDisk(string path, out GraphData graph) { try { - var textGraph = File.ReadAllText(path, Encoding.UTF8); + var textGraph = File.ReadAllText(PathToAbsolutePath(path), Encoding.UTF8); graph = new GraphData { messageManager = new Graphing.Util.MessageManager(),