浏览代码

Switch control's HDR argument to enum

/main
Matt Dean 7 年前
当前提交
f7209064
共有 3 个文件被更改,包括 22 次插入11 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/HDRColorNode.cs
  2. 29
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/DefaultControl.cs

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/HDRColorNode.cs


RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
[ColorControl("", true)]
[ColorControl("", ColorMode.HDR)]
public Color color
{
get { return m_Color; }

29
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs


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);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/DefaultControl.cs


public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
if (propertyInfo.PropertyType == typeof(Color))
return new ColorControlView(null, false, node, propertyInfo);
return new ColorControlView(null, ColorMode.Default, node, propertyInfo);
if (typeof(Enum).IsAssignableFrom(propertyInfo.PropertyType))
return new EnumControlView(null, node, propertyInfo);
if (propertyInfo.PropertyType == typeof(Texture2D))

正在加载...
取消
保存