暫無描述
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.

Vector2ShaderProperty.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using UnityEditor.Graphing;
  3. using UnityEngine;
  4. namespace UnityEditor.ShaderGraph.Internal
  5. {
  6. [Serializable]
  7. [FormerName("UnityEditor.ShaderGraph.Vector2ShaderProperty")]
  8. [BlackboardInputInfo(1)]
  9. public sealed class Vector2ShaderProperty : VectorShaderProperty
  10. {
  11. internal Vector2ShaderProperty()
  12. {
  13. displayName = "Vector2";
  14. }
  15. internal override int vectorDimension => 2;
  16. public override PropertyType propertyType => PropertyType.Vector2;
  17. internal override AbstractMaterialNode ToConcreteNode()
  18. {
  19. var node = new Vector2Node();
  20. node.FindInputSlot<Vector1MaterialSlot>(Vector2Node.InputSlotXId).value = value.x;
  21. node.FindInputSlot<Vector1MaterialSlot>(Vector2Node.InputSlotYId).value = value.y;
  22. return node;
  23. }
  24. internal override PreviewProperty GetPreviewMaterialProperty()
  25. {
  26. return new PreviewProperty(propertyType)
  27. {
  28. name = referenceName,
  29. vector4Value = value
  30. };
  31. }
  32. internal override ShaderInput Copy()
  33. {
  34. return new Vector2ShaderProperty()
  35. {
  36. displayName = displayName,
  37. value = value,
  38. };
  39. }
  40. internal override void ForeachHLSLProperty(Action<HLSLProperty> action)
  41. {
  42. HLSLDeclaration decl = GetDefaultHLSLDeclaration();
  43. action(new HLSLProperty(HLSLType._float2, referenceName, decl, concretePrecision));
  44. }
  45. public override int latestVersion => 1;
  46. public override void OnAfterDeserialize(string json)
  47. {
  48. if (sgVersion == 0)
  49. {
  50. LegacyShaderPropertyData.UpgradeToHLSLDeclarationOverride(json, this);
  51. ChangeVersion(1);
  52. }
  53. }
  54. }
  55. }