暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Vector4ShaderProperty.cs 2.1KB

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