Vector2ShaderProperty.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using UnityEditor.Graphing;
  3. using UnityEngine;
  4. namespace UnityEditor.ShaderGraph.Internal
  5. {
  6. [Serializable]
  7. [FormerName("UnityEditor.ShaderGraph.Vector2ShaderProperty")]
  8. public sealed class Vector2ShaderProperty : VectorShaderProperty
  9. {
  10. internal Vector2ShaderProperty()
  11. {
  12. displayName = "Vector2";
  13. }
  14. public override PropertyType propertyType => PropertyType.Vector2;
  15. internal override AbstractMaterialNode ToConcreteNode()
  16. {
  17. var node = new Vector2Node();
  18. node.FindInputSlot<Vector1MaterialSlot>(Vector2Node.InputSlotXId).value = value.x;
  19. node.FindInputSlot<Vector1MaterialSlot>(Vector2Node.InputSlotYId).value = value.y;
  20. return node;
  21. }
  22. internal override PreviewProperty GetPreviewMaterialProperty()
  23. {
  24. return new PreviewProperty(propertyType)
  25. {
  26. name = referenceName,
  27. vector4Value = value
  28. };
  29. }
  30. internal override ShaderInput Copy()
  31. {
  32. return new Vector2ShaderProperty()
  33. {
  34. displayName = displayName,
  35. hidden = hidden,
  36. value = value
  37. };
  38. }
  39. }
  40. }