✅ Get delegate from event

I got class
public static class Events
{
  public static PlayerEvents Player { get; } = new PlayerEvents();
}

and PlayerEvents class contains
public class PlayerEvents
{
    public event Event<PlayerLeftServer> Leaving;

    public event Event<PlayerLeftServer> Left;
}


I want to get delegate from Leaving/Left event but seems like while trying to get value its null? idk

            foreach (var property in typeof(Events).GetProperties(BindingFlags.Public | BindingFlags.Static))
            {
                foreach (var ev in property.PropertyType.GetEvents())
                {
                    FieldInfo evField = property.PropertyType.GetField(ev.Name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.GetField);

                    // GetValue returns null
                    Debug.Log(evField.GetValue(property.GetValue(null, null)));
                }
            }
Was this page helpful?