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