Custom UnityEvent in Editor Window

I have searched high a low for a solution to this. All I seem to find are answers related to serialized objects which don’t work in my case.


Long story short the events I am trying to "serialize" is not attached to a game object. It is a basic static field for an editor window. So pretty much I need a way to display the default inspector drawer for unity events without an object tied to it where you would use SerializedProperty to get that default functionality.
Any ideas?
public class CustomEvent : UnityEvent<MyType>
{ }

public MyWindow : EditorWindow
{
     public static CustomEvent onSomething { get; } = new CustomEvent();

     private void OnGUI()
     {
          //what do I do here to allow the user to add Subscriptions? Can't figure it out
     }
}

I’d really appreciate the help thanks!

Your setup doesn’t make much sense. Static fields are not serialized at all and won’t survive an assembly reload. So letting the user assigning references to assets or even objects in the scene doesn’t make sense.

Serialization in general only works on objects. Why exactly can’t you use an object? Also what events do you want the user to assign? References to objects in a scene can only be stored in the scene itself.

Probably the best solution would be to use a ScriptableObject which is created in memory and stored along with the scene (if you want the user to assign references to objects in the sceme) or just use a ScriptableObject that is stored in the project as asset (in this case you can only reference other assets like prefabs or ScriptalbeObject; No references to objects in the scene are possible).