Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 12 additions & 3 deletions Packages/com.unity.shadergraph/Editor/Util/FileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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(),
Expand Down