|
|
|
|
|
|
|
|
|
|
namespace UnityEditor.ShaderGraph.Drawing.Controls |
|
|
|
{ |
|
|
|
public enum ColorMode |
|
|
|
{ |
|
|
|
Default, |
|
|
|
HDR |
|
|
|
} |
|
|
|
|
|
|
|
bool m_Hdr; |
|
|
|
ColorMode m_ColorMode; |
|
|
|
public ColorControlAttribute(string label = null, bool hdr = false) |
|
|
|
public ColorControlAttribute(string label = null, ColorMode colorMode = ColorMode.Default) |
|
|
|
m_Hdr = hdr; |
|
|
|
m_ColorMode = colorMode; |
|
|
|
return new ColorControlView(m_Label, m_Hdr, node, propertyInfo); |
|
|
|
return new ColorControlView(m_Label, m_ColorMode, node, propertyInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
PropertyInfo m_PropertyInfo; |
|
|
|
|
|
|
|
public ColorControlView(string label, bool hdr, AbstractMaterialNode node, PropertyInfo propertyInfo) |
|
|
|
public ColorControlView(string label, ColorMode colorMode, AbstractMaterialNode node, PropertyInfo propertyInfo) |
|
|
|
{ |
|
|
|
m_Node = node; |
|
|
|
m_PropertyInfo = propertyInfo; |
|
|
|
|
|
|
Add(new Label(label)); |
|
|
|
|
|
|
|
ColorField colorField; |
|
|
|
if(hdr) |
|
|
|
colorField = new ColorField { value = (Color)m_PropertyInfo.GetValue(m_Node, null), hdr = true }; |
|
|
|
else |
|
|
|
colorField = new ColorField { value = (Color)m_PropertyInfo.GetValue(m_Node, null) }; |
|
|
|
switch(colorMode) |
|
|
|
{ |
|
|
|
case ColorMode.HDR: |
|
|
|
colorField = new ColorField { value = (Color)m_PropertyInfo.GetValue(m_Node, null), hdr = true }; |
|
|
|
break; |
|
|
|
default: |
|
|
|
colorField = new ColorField { value = (Color)m_PropertyInfo.GetValue(m_Node, null) }; |
|
|
|
break; |
|
|
|
} |
|
|
|
colorField.OnValueChanged(OnChange); |
|
|
|
Add(colorField); |
|
|
|
} |
|
|
|