Need to inherit from EventArgs AND ScriptableObject

I’m in a situation where I need to inherit from both EventArgs and ScriptableObject.

I can’t see a way of achieving this, as I can’t alter System.EventArgs implementation to use an interface, nor ScriptableObjects.

Am I going about this all wrong?

I want to be able to use the [CreateAssetMenu()] (from ScriptableObject) to create a new EventArgs subclass… But it still needs to inherit from EventArgs to match my delegate method signature…

Any ideas?

This is not possible.

Can’t you simply create another class inheriting from EventArgs with a simple getter&setter to access the instance of the Scriptable Object?

Create two classes :

  1. One inheriting from ScriptableObject with the CreateAssetMenu attribute, and all the data you need

  2. Another one, inheriting from EventArgs containing a simple reference to an instance of the class declared above

    [CreateAssetMenu()]
    public class MySO : ScriptableObject
    {
    // … your data
    }

    public class MySOEventArgs : EventArgs
    {
    public MySO SO { get ; private set ;}
    public MySOEventArgs( MySO so ) { SO = so ; }

    }

    // … Somewhere in your code:

    public event EventHandler SomethingHappened;
    public void RaiseEvent( MySO mySOInstance )
    {
    MySOEventArgs args = new MySOEventArgs( mySOInstance );
    if( SomethingHappened != null )
    SomethingHappened( this, args ) ;
    }