LMQT/Assets/TouchScript/Editor/Utils/PropertyDrawers/ToggleLeftDrawer.cs
2024-12-10 09:03:45 +08:00

28 lines
833 B
C#

/*
* @author Valentin Simonov / http://va.lent.in/
*/
using TouchScript.Utils.Attributes;
using UnityEditor;
using UnityEngine;
namespace TouchScript.Editor.Utils.PropertyDrawers
{
[CustomPropertyDrawer(typeof(ToggleLeftAttribute))]
internal sealed class ToggleLeftDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
label = EditorGUI.BeginProperty(position, label, property);
label.text = " " + label.text;
EditorGUI.BeginChangeCheck();
var boolValue = EditorGUI.ToggleLeft(position, label, property.boolValue);
if (EditorGUI.EndChangeCheck())
{
property.boolValue = boolValue;
}
EditorGUI.EndProperty();
}
}
}