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,3 @@
fileFormatVersion: 2
guid: c31ec81529dc4f3fb828508c80171ff6
timeCreated: 1749825893
@@ -0,0 +1,22 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace Events
{
[CustomEditor(typeof(EventBroker))]
public class EventBrokerEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (!EditorApplication.isPlaying) return;
if (GUILayout.Button("Player Died"))
{
(target as EventBroker)?.RaisePlayerDied();
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 12b0037e847a41a1b18c0ef2643e47a8
timeCreated: 1749825911
@@ -0,0 +1,13 @@
using System;
using UnityEngine;
namespace Events
{
[CreateAssetMenu(fileName = "EventBroker", menuName = "Events/Event Broker", order = 0)]
public class EventBroker : ScriptableObject
{
public event Action PlayerDied;
public void RaisePlayerDied() => PlayerDied?.Invoke();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c52cbf4a02ec44f3a6b94e25b84593d9
timeCreated: 1749825311