public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { EditorGUI.BeginProperty(position, label, prop); int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text, (attribute as SingleLineAttribute).Tooltip)); switch (prop.type) { case "RangeOfIntegers": PropertyDrawerExtensions.DrawRangeField(this, position, prop, false); break; case "RangeOfFloats": PropertyDrawerExtensions.DrawRangeField(this, position, prop, true); break; default: EditorGUI.HelpBox(position, "[SingleLineDrawer] doesn't work with type '" + prop.type + "'", MessageType.Error); break; } EditorGUI.indentLevel = indent; EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { string tooltip = (attribute as SingleLineAttribute).Tooltip; label.tooltip = tooltip; Rect origPosition = position; EditorGUI.BeginProperty(position, label, prop); int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; switch (prop.type) { case "RangeOfIntegers": PropertyDrawerExtensions.DrawRangeField(this, position, prop, label, false); break; case "RangeOfFloats": PropertyDrawerExtensions.DrawRangeField(this, position, prop, label, true); break; case "Vector4": EditorGUI.BeginChangeCheck(); Vector4 v4 = EditorGUI.Vector4Field(origPosition, label, prop.vector4Value); if (EditorGUI.EndChangeCheck()) { prop.vector4Value = v4; } int newRows = EditorGUIUtility.currentViewWidth <= 332.5f ? 2 : 1; if (rows != newRows) { rows = newRows; if (EditorApplication.update != null) { EditorApplication.update.Invoke(); } } break; default: EditorGUI.HelpBox(position, "[SingleLineDrawer] doesn't work with type '" + prop.type + "'", MessageType.Error); break; } EditorGUI.indentLevel = indent; EditorGUI.EndProperty(); }