Files
gpd-924-en/EditorCustomization/Assets/Scripts/Data/Editor/CharacterAttributesDrawer.cs
T
david a6dbfb224f add scriptable object examples
add editor window example
add attribute + drawer example
2025-06-13 18:07:18 +02:00

28 lines
931 B
C#

using Core;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace Data
{
[CustomPropertyDrawer(typeof(CharacterAttributes))]
public class CharacterAttributesDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
position = EditorGUI.PrefixLabel(position, label);
position.width *= 0.75f;
EditorGUI.PropertyField(position, property, GUIContent.none);
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();
}
}
}
}