您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
78 行
1.9 KiB
78 行
1.9 KiB
using System;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.ShaderGraph
|
|
{
|
|
[Serializable]
|
|
public class ColorShaderProperty : AbstractShaderProperty<Color>
|
|
{
|
|
[SerializeField]
|
|
private bool m_HDR;
|
|
|
|
public bool HDR
|
|
{
|
|
get { return m_HDR; }
|
|
set
|
|
{
|
|
if (m_HDR == value)
|
|
return;
|
|
|
|
m_HDR = value;
|
|
}
|
|
}
|
|
|
|
public ColorShaderProperty()
|
|
{
|
|
displayName = "Color";
|
|
}
|
|
|
|
public override PropertyType propertyType
|
|
{
|
|
get { return PropertyType.Color; }
|
|
}
|
|
|
|
public override Vector4 defaultValue
|
|
{
|
|
get { return new Vector4(value.r, value.g, value.b, value.a); }
|
|
}
|
|
|
|
public override string GetPropertyBlockString()
|
|
{
|
|
if (!generatePropertyBlock)
|
|
return string.Empty;
|
|
|
|
var result = new StringBuilder();
|
|
if (HDR)
|
|
result.Append("[HDR]");
|
|
result.Append(referenceName);
|
|
result.Append("(\"");
|
|
result.Append(displayName);
|
|
result.Append("\", Color) = (");
|
|
result.Append(value.r);
|
|
result.Append(",");
|
|
result.Append(value.g);
|
|
result.Append(",");
|
|
result.Append(value.b);
|
|
result.Append(",");
|
|
result.Append(value.a);
|
|
result.Append(")");
|
|
return result.ToString();
|
|
}
|
|
|
|
public override string GetPropertyDeclarationString()
|
|
{
|
|
return "float4 " + referenceName + ";";
|
|
}
|
|
|
|
public override PreviewProperty GetPreviewMaterialProperty()
|
|
{
|
|
return new PreviewProperty
|
|
{
|
|
name = referenceName,
|
|
propType = PropertyType.Color,
|
|
colorValue = value
|
|
};
|
|
}
|
|
}
|
|
}
|