SamplerStateShaderProperty.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using UnityEditor.Graphing;
  3. using UnityEditor.ShaderGraph.Internal;
  4. using UnityEngine;
  5. namespace UnityEditor.ShaderGraph
  6. {
  7. class SamplerStateShaderProperty : AbstractShaderProperty<TextureSamplerState>
  8. {
  9. public SamplerStateShaderProperty()
  10. {
  11. displayName = "SamplerState";
  12. value = new TextureSamplerState();
  13. }
  14. public override PropertyType propertyType => PropertyType.SamplerState;
  15. internal override bool isBatchable => false;
  16. internal override bool isExposable => false;
  17. internal override bool isRenamable => false;
  18. public override TextureSamplerState value
  19. {
  20. get => base.value;
  21. set
  22. {
  23. overrideReferenceName = $"{concreteShaderValueType.ToShaderString()}_{value.filter}_{value.wrap}";
  24. base.value = value;
  25. }
  26. }
  27. internal override string GetPropertyDeclarationString(string delimiter = ";")
  28. {
  29. return $"SAMPLER({referenceName}){delimiter}";
  30. }
  31. internal override string GetPropertyAsArgumentString()
  32. {
  33. return $"SamplerState {referenceName}";
  34. }
  35. internal override AbstractMaterialNode ToConcreteNode()
  36. {
  37. return new SamplerStateNode()
  38. {
  39. filter = value.filter,
  40. wrap = value.wrap
  41. };
  42. }
  43. internal override PreviewProperty GetPreviewMaterialProperty()
  44. {
  45. return default(PreviewProperty);
  46. }
  47. internal override ShaderInput Copy()
  48. {
  49. return new SamplerStateShaderProperty()
  50. {
  51. displayName = displayName,
  52. hidden = hidden,
  53. overrideReferenceName = overrideReferenceName,
  54. value = value
  55. };
  56. }
  57. }
  58. }