Listen to a Monobehaviour default method from another Game Object?

So I have a Game Object with the following simple MonoBehaviour (note I’ve made OnBecameInvisible public!)

using UnityEngine;
using System.Collections;

public class ShowHide: MonoBehaviour
{
    public void OnBecameInvisible()
    {
        Debug.Log("ASSERT becameInvisible and name " + name);
        //enabled = false;
    }

    public void OnBecameVisible()
    {
#if UNITY_EDITOR
        if (Camera.current.name == "SceneCamera")
            return;
#endif
        // enabled = true;
        Debug.Log("ASSERT becameVisible and name " + name);
    }
}

On another Game Object I want to know when the above OnBecameInvisible() gets called.

So I am trying, but not really sure how to properly implement

GameObject foo;
foo.GetComponent<ShowHide>().OnBecameInvisible().....

Use an event:

using UnityEngine;
using System.Collections;

public class ShowHide: MonoBehaviour
{
  
    public event System.EventHandler BecameInvisible;
  
    protected void OnBecameInvisible()
    {
        Debug.Log("ASSERT becameInvisible and name " + name);
        //enabled = false;
        if(BecameInvisible != null) BecameInvisible(this, System.EventArgs.Empty);
    }

    protected void OnBecameVisible()
    {
#if UNITY_EDITOR
        if (Camera.current.name == "SceneCamera")
            return;
#endif
        // enabled = true;
        Debug.Log("ASSERT becameVisible and name " + name);
    }
}

Then:

GameObject foo;
foo.GetComponent<ShowHide>().BecameInvisible += this.OnBecameInvisibleHandler;

//... in same class scope

private void OnBecameInvisibleHandler(object sender, System.EventArgs e)
{
    //react to foo becoming Invisible
}

Why the EventHandler design over a Func or a custom delegate?

You’re sending an untyped object and a wrapper for no arguments, I can’t really see why.

Honestly… it’s because I habitually just use the EventHandler design, been writing C# for years.

The structure allows that any handler that follows the default structure can be assigned to any arbitrary event.