force OnEnable on scriptable objects

Hi,

I am trying to implement an scriptable object based event system.
Events and event listeners are both scriptable objects so they can live in the project rather than the scene.
This makes it easy to reference either from other assets from the project or objects in the scene.

Listeners register must register to events and I thought I could do this in the OnEnable callback of the scriptable object. But then I found OnEnable doesn’t get called unless you instanciate the prefab, or select it on the editor. So then they never execute OnEnable thus never register to the listener.

Is there anyway I can do this that doesnt imply manually refering them in a monobehaviour in the scene? Thanks!

Just in case somebody find this question, I could’t find an easy solution so what I did is:

  1. Create a derived class from scriptable object with functions for the callbacks, I called it monoscriptableObject.
  2. Create a scriptable object with a list that references the scriptable objects I want to receibe normal monobehaviours callbacks, I called it MonoCallBacks.
  3. Create a monobehaviour with a reference to the list in point 2 that calls those functions when their callbacks are called. ie. OnEnable() { foreach mso in list { mso.OnEnableCallBack() }}
  4. Have an instance in your scene of MonoCallBacks.

Hope this helps somebody