BooleanShaderProperty.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Text;
  3. using UnityEditor.Graphing;
  4. using UnityEditor.ShaderGraph.Drawing.Controls;
  5. using UnityEngine;
  6. namespace UnityEditor.ShaderGraph.Internal
  7. {
  8. [Serializable]
  9. [FormerName("UnityEditor.ShaderGraph.BooleanShaderProperty")]
  10. public sealed class BooleanShaderProperty : AbstractShaderProperty<bool>
  11. {
  12. internal BooleanShaderProperty()
  13. {
  14. displayName = "Boolean";
  15. }
  16. public override PropertyType propertyType => PropertyType.Boolean;
  17. internal override bool isBatchable => true;
  18. internal override bool isExposable => true;
  19. internal override bool isRenamable => true;
  20. internal override string GetPropertyBlockString()
  21. {
  22. return $"{hideTagString}[ToggleUI]{referenceName}(\"{displayName}\", Float) = {(value == true ? 1 : 0)}";
  23. }
  24. internal override AbstractMaterialNode ToConcreteNode()
  25. {
  26. return new BooleanNode { value = new ToggleData(value) };
  27. }
  28. internal override PreviewProperty GetPreviewMaterialProperty()
  29. {
  30. return new PreviewProperty(propertyType)
  31. {
  32. name = referenceName,
  33. booleanValue = value
  34. };
  35. }
  36. internal override ShaderInput Copy()
  37. {
  38. return new BooleanShaderProperty()
  39. {
  40. displayName = displayName,
  41. hidden = hidden,
  42. value = value
  43. };
  44. }
  45. }
  46. }