Skip to content

Commit 7491cb9

Browse files
Esmeralda SalamoneEvergreen
authored andcommitted
[ShaderGraph] lazy enable asset post processor for provider cache
1 parent 87d0a8c commit 7491cb9

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

Packages/com.unity.shadergraph/Editor/ProviderSystem/ProviderLibrary.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace UnityEditor.ShaderGraph.ProviderSystem
77
internal class ProviderLibrary
88
{
99
static ProviderLibrary s_instance;
10+
11+
internal static bool IsInstanceInitialized => s_instance != null;
1012
internal static ProviderLibrary Instance
1113
{
1214
get

Packages/com.unity.shadergraph/Editor/ProviderSystem/Reflection/ShaderReflectionAssetPostProcessor.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
using UnityEditor.ShaderApiReflection;
33
using System.Collections.Generic;
44
using UnityEditor.ShaderGraph.Drawing;
5+
using System.IO;
56

67
namespace UnityEditor.ShaderGraph.ProviderSystem
78
{
89
internal class ShaderReflectionAssetPostProcessor : AssetPostprocessor
910
{
1011
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
1112
{
13+
if (!ProviderLibrary.IsInstanceInitialized)
14+
return;
15+
1216
List<GUID> modifiedFiles = new();
1317
foreach (string path in importedAssets)
1418
{
19+
if (Path.GetExtension(path).ToLower() != ".hlsl")
20+
continue;
21+
1522
var assetID = AssetDatabase.GUIDFromAssetPath(path);
1623
if (ProviderLibrary.Instance.AnalyzeFile(assetID))
1724
{
@@ -31,7 +38,5 @@ internal static void NotifyAll(IEnumerable<GUID> modifiedFiles)
3138
editor.NotifyDependencyUpdated(modifiedFiles);
3239
}
3340
}
34-
35-
3641
}
3742
}

0 commit comments

Comments
 (0)