add scriptable object examples

add editor window example
add attribute + drawer example
This commit is contained in:
2025-06-13 18:07:18 +02:00
parent 0ae837c57b
commit a6dbfb224f
52 changed files with 1460 additions and 533 deletions
@@ -0,0 +1,28 @@
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();
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 484559cbb76043e19a4cacc8b753bebf
timeCreated: 1749829051
@@ -0,0 +1,23 @@
using Core;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace Data
{
[CustomEditor(typeof(CharacterAttributes))]
public class CharacterAttributesEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (GUILayout.Button("Open Character Attributes Editor"))
{
CharacterAttributesWindow window = EditorWindow.GetWindow<CharacterAttributesWindow>();
window.CharacterAttributesToEdit = target as CharacterAttributes;
window.Show();
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 272269d36d454d6cbd79b57adc9f2692
timeCreated: 1749828536