Help with delegates

I got this error and I can’t see what’s wrong with it… I have abunch of other delegates which works just fine

“TillHead.cs(22,33): error CS0019: Operator +=' cannot be applied to operands of type EventHandler.EO_SmallImpact’ and `void’”

EventHandler.cs:

public delegate void EO_SmallImpact();
public static EO_SmallImpact EO_OnSmallImpact;

public static void EO_OnSmallImpactEvent()
    {
        if (EO_OnSmallImpact != null)
            EO_OnSmallImpact();
    }

Tillhead.cs:

void OnEnable()
    {
        EventHandler.EO_OnSmallImpact += this.OnSmallImpact ();
    }

    void OnDisable()
    {
        EventHandler.EO_OnSmallImpact -= this.OnSmallImpact ();
    }

Am I blind? :slight_smile:

I think you code complete is trolling you. Just remove referent to execute method :

Tillhead.cs (become this)

void OnEnable()
    {
        EventHandler.EO_OnSmallImpact += this.OnSmallImpact;
    }
    void OnDisable()
    {
        EventHandler.EO_OnSmallImpact -= this.OnSmallImpact;
    }
1 Like

omg… I was blind :smile: Thank you! :slight_smile: