浏览代码

Fix adding Slider and Int properties from inline node conversion

/main
Matt Dean 7 年前
当前提交
78f31c8e
共有 1 个文件被更改,包括 45 次插入7 次删除
  1. 52
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardFieldPropertyView.cs

52
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardFieldPropertyView.cs


VisualElement modeRow = new VisualElement();
VisualElement minRow = new VisualElement();
VisualElement maxRow = new VisualElement();
FloatField floatField = null;
var field = new FloatField { value = floatProperty.value };
field.OnValueChanged(evt =>
if(floatProperty.floatType == FloatType.Integer)
floatProperty.value = (float)evt.newValue;
DirtyNodes();
});
floatRow = AddRow("Default", field);
var field = new IntegerField { value = (int)floatProperty.value };
field.OnValueChanged(intEvt =>
{
floatProperty.value = (float)intEvt.newValue;
DirtyNodes();
});
intRow = AddRow("Default", field);
}
else
{
floatField = new FloatField { value = floatProperty.value };
floatField.OnValueChanged(evt =>
{
floatProperty.value = (float)evt.newValue;
DirtyNodes();
});
floatRow = AddRow("Default", floatField);
}
var floatModeField = new EnumField((Enum)floatProperty.floatType);
floatModeField.value = floatProperty.floatType;
floatModeField.OnValueChanged(evt =>

{
case FloatType.Slider:
RemoveElements(new VisualElement[]{floatRow, intRow, modeRow, minRow, maxRow});
field = new FloatField { value = Mathf.Max(Mathf.Min(floatProperty.value, floatProperty.rangeValues.y), floatProperty.rangeValues.x) };
var field = new FloatField { value = Mathf.Max(Mathf.Min(floatProperty.value, floatProperty.rangeValues.y), floatProperty.rangeValues.x) };
floatProperty.value = (float)field.value;
field.OnValueChanged(defaultEvt =>
{

DirtyNodes();
});
modeRow = AddRow("Mode", floatModeField);
if(floatProperty.floatType == FloatType.Slider)
{
var minField = new FloatField { value = floatProperty.rangeValues.x };
minField.OnValueChanged(minEvt =>
{
floatProperty.rangeValues = new Vector2((float)minEvt.newValue, floatProperty.rangeValues.y);
floatProperty.value = Mathf.Max(Mathf.Min(floatProperty.value, floatProperty.rangeValues.y), floatProperty.rangeValues.x);
floatField.value = floatProperty.value;
DirtyNodes();
});
minRow = AddRow("Min", minField);
var maxField = new FloatField { value = floatProperty.rangeValues.y };
maxField.OnValueChanged(maxEvt =>
{
floatProperty.rangeValues = new Vector2(floatProperty.rangeValues.x, (float)maxEvt.newValue);
floatProperty.value = Mathf.Max(Mathf.Min(floatProperty.value, floatProperty.rangeValues.y), floatProperty.rangeValues.x);
floatField.value = floatProperty.value;
DirtyNodes();
});
maxRow = AddRow("Max", maxField);
}
}
else if (property is Vector2ShaderProperty)
{

正在加载...
取消
保存