30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Data.Editor
|
|
{
|
|
[CustomPropertyDrawer(typeof(CharacterAttributes))]
|
|
public class CharacterAttributesDrawer : PropertyDrawer
|
|
{
|
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
|
{
|
|
bool isNull = property.objectReferenceValue == null;
|
|
|
|
position = EditorGUI.PrefixLabel(position, label);
|
|
|
|
if (!isNull) position.width *= 0.75f;
|
|
EditorGUI.PropertyField(position, property, GUIContent.none);
|
|
|
|
if (isNull) return;
|
|
|
|
position.x += position.width;
|
|
position.width *= 0.3333333f;
|
|
if (GUI.Button(position, "Open"))
|
|
{
|
|
CharacterAttributesWindow window = EditorWindow.GetWindow<CharacterAttributesWindow>();
|
|
window.CharacterAttributesToEdit = property.objectReferenceValue as CharacterAttributes;
|
|
window.Show();
|
|
}
|
|
}
|
|
}
|
|
} |