您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
55 行
1.5 KiB
55 行
1.5 KiB
using System;
|
|
using UnityEditor.Graphing;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.ShaderGraph
|
|
{
|
|
[Serializable]
|
|
public class Vector2ShaderProperty : VectorShaderProperty
|
|
{
|
|
public Vector2ShaderProperty()
|
|
{
|
|
displayName = "Vector2";
|
|
}
|
|
|
|
public override PropertyType propertyType
|
|
{
|
|
get { return PropertyType.Vector2; }
|
|
}
|
|
|
|
public override Vector4 defaultValue
|
|
{
|
|
get { return new Vector4(value.x, value.y, 0, 0); }
|
|
}
|
|
|
|
public override string GetPropertyDeclarationString(string delimiter = ";")
|
|
{
|
|
return string.Format("float2 {0}{1}", referenceName, delimiter);
|
|
}
|
|
|
|
public override PreviewProperty GetPreviewMaterialProperty()
|
|
{
|
|
return new PreviewProperty(PropertyType.Vector2)
|
|
{
|
|
name = referenceName,
|
|
vector4Value = value
|
|
};
|
|
}
|
|
|
|
public override INode ToConcreteNode()
|
|
{
|
|
var node = new Vector2Node();
|
|
node.FindInputSlot<Vector1MaterialSlot>(Vector2Node.InputSlotXId).value = value.x;
|
|
node.FindInputSlot<Vector1MaterialSlot>(Vector2Node.InputSlotYId).value = value.y;
|
|
return node;
|
|
}
|
|
|
|
public override IShaderProperty Copy()
|
|
{
|
|
var copied = new Vector2ShaderProperty();
|
|
copied.displayName = displayName;
|
|
copied.value = value;
|
|
return copied;
|
|
}
|
|
}
|
|
}
|