public override void Apply(MaterialProperty prop) { base.Apply(prop); if (MaterialToggleLeftDrawer.IsPropertyTypeSuitable(prop)) { if (!prop.hasMixedValue) { this.SetKeyword(prop, Math.Abs(prop.floatValue) > 0.001f); } } }
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) { float result; if (!MaterialToggleLeftDrawer.IsPropertyTypeSuitable(prop)) { result = 40f; } else { result = base.GetPropertyHeight(prop, label, editor); } return(result); }
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { if (!MaterialToggleLeftDrawer.IsPropertyTypeSuitable(prop)) { EditorGUI.HelpBox(position, "Toggle used on a non-float property: " + prop.name, MessageType.Error); } else { EditorGUI.BeginChangeCheck(); bool flag = Math.Abs(prop.floatValue) > 0.001f; EditorGUI.showMixedValue = prop.hasMixedValue; flag = EditorGUI.ToggleLeft(position, label, flag); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { prop.floatValue = ((!flag) ? 0f : 1f); this.SetKeyword(prop, flag); } } }