Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

AssetCollection.cs 1.7KB

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