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

Vector3ShaderProperty.cs 2.0KB

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