浏览代码

Merge pull request #286 from Unity-Technologies/trunk-compatibility

More trunk compatibility fixes
/main
GitHub 6 年前
当前提交
685fecd6
共有 4 个文件被更改,包括 37 次插入8 次删除
  1. 7
      com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardFieldPropertyView.cs
  2. 12
      com.unity.shadergraph/Editor/Drawing/Controls/IntegerControl.cs
  3. 8
      com.unity.shadergraph/Editor/Drawing/Controls/ToggleControl.cs
  4. 18
      com.unity.shadergraph/Editor/Util/CompatibilityExtensions.cs

7
com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardFieldPropertyView.cs


else if (property is BooleanShaderProperty)
{
var booleanProperty = (BooleanShaderProperty)property;
Action onBooleanChanged = () =>
{
Action onBooleanChanged = () =>
{
var field = new Toggle(onBooleanChanged) { on = booleanProperty.value };
var field = new Toggle(onBooleanChanged);
field.SetValue(booleanProperty.value);
AddRow("Default", field);
}
// AddRow("Type", new TextField());

12
com.unity.shadergraph/Editor/Drawing/Controls/IntegerControl.cs


var intField = new IntegerField { value = (int)m_PropertyInfo.GetValue(m_Node, null) };
intField.OnValueChanged(OnChange);
#if UNITY_2018_1
#else
void OnChange(ChangeEvent<int> evt)
#endif
m_PropertyInfo.SetValue(m_Node, (int)evt.newValue, null);
var newValue =
#if UNITY_2018_1
(int)
#endif
evt.newValue;
m_PropertyInfo.SetValue(m_Node, newValue, null);
Dirty(ChangeType.Repaint);
}
}

8
com.unity.shadergraph/Editor/Drawing/Controls/ToggleControl.cs


if (propertyInfo.PropertyType != typeof(Toggle))
throw new ArgumentException("Property must be a Toggle.", "propertyInfo");
label = label ?? ObjectNames.NicifyVariableName(propertyInfo.Name);
var value = (Toggle)m_PropertyInfo.GetValue(m_Node, null);

Action changedToggle = () => { OnChangeToggle(); };
m_Toggle = new UnityEngine.Experimental.UIElements.Toggle(changedToggle);
m_Toggle.SetEnabled(value.isEnabled);
m_Toggle.on = value.isOn;
m_Toggle.SetValue(value.isOn);
panel.Add(m_Toggle);
Add(panel);
}

var value = (Toggle)m_PropertyInfo.GetValue(m_Node, null);
m_Toggle.SetEnabled(value.isEnabled);
}
}
}
void OnChangeToggle()

18
com.unity.shadergraph/Editor/Util/CompatibilityExtensions.cs


Debug.Assert(action != null);
contextualMenu.AppendAction(actionName, e => action(), e => statusFlags);
}
public static bool GetValue(this Toggle toggle)
{
#if UNITY_2018_1
return toggle.on;
#else
return toggle.value;
#endif
}
public static void SetValue(this Toggle toggle, bool value)
{
#if UNITY_2018_1
toggle.on = value;
#else
toggle.value = value;
#endif
}
}
}
正在加载...
取消
保存