Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ShaderGraphMetadata.cs 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEditor.ShaderGraph.Internal;
  5. using UnityEngine;
  6. using Object = UnityEngine.Object;
  7. namespace UnityEditor.ShaderGraph
  8. {
  9. [Serializable]
  10. struct GraphInputData
  11. {
  12. public string referenceName;
  13. public bool isKeyword;
  14. public PropertyType propertyType;
  15. public KeywordType keywordType;
  16. public bool isCompoundProperty;
  17. public List<SubPropertyData> subProperties;
  18. }
  19. [Serializable]
  20. struct SubPropertyData
  21. {
  22. public string referenceName;
  23. public PropertyType propertyType;
  24. }
  25. [Serializable]
  26. class MinimalCategoryData
  27. {
  28. // ShaderLab doesn't understand virtual texture inputs, they need to be processed to replace the virtual texture input with the layers that compose it instead
  29. public static GraphInputData ProcessVirtualTextureProperty(VirtualTextureShaderProperty virtualTextureShaderProperty)
  30. {
  31. var layerReferenceNames = new List<string>();
  32. virtualTextureShaderProperty.GetPropertyReferenceNames(layerReferenceNames);
  33. var virtualTextureLayerDataList = new List<SubPropertyData>();
  34. // Skip the first entry in this list as that's the Virtual Texture reference name itself, which won't exist in ShaderLab
  35. foreach (var referenceName in layerReferenceNames.Skip(1))
  36. {
  37. var layerPropertyData = new SubPropertyData() { referenceName = referenceName, propertyType = PropertyType.Texture2D };
  38. virtualTextureLayerDataList.Add(layerPropertyData);
  39. }
  40. var virtualTexturePropertyData = new GraphInputData() { referenceName = virtualTextureShaderProperty.displayName, propertyType = PropertyType.VirtualTexture, isKeyword = false };
  41. virtualTexturePropertyData.isCompoundProperty = true;
  42. virtualTexturePropertyData.subProperties = virtualTextureLayerDataList;
  43. return virtualTexturePropertyData;
  44. }
  45. public string categoryName;
  46. public List<GraphInputData> propertyDatas;
  47. [NonSerialized]
  48. public bool expanded = true;
  49. }
  50. class ShaderGraphMetadata : ScriptableObject
  51. {
  52. public string outputNodeTypeName;
  53. // these asset dependencies are stored here as a way for "Export Package..." to discover them
  54. // and automatically pull them in to the .unitypackage
  55. public List<Object> assetDependencies;
  56. public List<MinimalCategoryData> categoryDatas;
  57. }
  58. }