_xiaofang/xiaofang/Assets/Obi/Editor/RopeAndRod/IgnoredBoneDrawer.cs
杨号敬 bcc74f0465 add
2024-12-18 02:18:45 +08:00

31 lines
1.3 KiB
C#

using UnityEngine;
using UnityEditor;
namespace Obi
{
[CustomPropertyDrawer(typeof(ObiBone.IgnoredBone))]
public class IgnoredBoneDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
GUI.Box(EditorGUI.IndentedRect(position), GUIContent.none, ObiEditorUtils.GetToggleablePropertyGroupStyle());
var rect = new Rect(position.x + 4, position.y + EditorGUIUtility.standardVerticalSpacing, position.width - 8, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(rect, property.FindPropertyRelative("bone"), label);
rect.position = new Vector2(rect.position.x, rect.position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
EditorGUI.PropertyField(rect, property.FindPropertyRelative("ignoreChildren"));
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
int lineCount = 2;
return EditorGUIUtility.singleLineHeight * lineCount + EditorGUIUtility.standardVerticalSpacing * (lineCount + 1);
}
}
}