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