A game about forced loneliness, made by TACStudios
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5namespace UnityEditor.ShaderGraph
6{
7 // this class is used to track asset dependencies in shadergraphs and subgraphs
8 // that is: it tracks files that the shadergraph or subgraph must access to generate the shader
9 // this data is used to automatically re-import the shadergraphs or subgraphs when any of the tracked files change
10 [GenerationAPI]
11 internal class AssetCollection
12 {
13 [Flags]
14 public enum Flags
15 {
16 SourceDependency = 1 << 0, // ShaderGraph directly reads the source file in the Assets directory
17 ArtifactDependency = 1 << 1, // ShaderGraph reads the import result artifact (i.e. subgraph import)
18 IsSubGraph = 1 << 2, // This asset is a SubGraph (used when we need to get multiple levels of dependencies)
19 IncludeInExportPackage = 1 << 3 // This asset should be pulled into any .unitypackages built via "Export Package.."
20 }
21
22 internal Dictionary<GUID, Flags> assets = new Dictionary<GUID, Flags>();
23
24 internal IEnumerable<GUID> assetGUIDs { get { return assets.Keys; } }
25
26 public AssetCollection()
27 {
28 }
29
30 internal void Clear()
31 {
32 assets.Clear();
33 }
34
35 // these are assets that we read the source files directly (directly reading the file out of the Assets directory)
36 public void AddAssetDependency(GUID assetGUID, Flags flags)
37 {
38 if (assets.TryGetValue(assetGUID, out Flags existingFlags))
39 {
40 assets[assetGUID] = existingFlags | flags;
41 }
42 else
43 {
44 assets.Add(assetGUID, flags);
45 }
46 }
47 }
48}