NullReferenceException при установке значение массива

Для игры деляю кастомную систему событий юнити, и даже определяет помеченые аттрибутом методы, но когда пытаюсь записать в массив MethodInfo MethodInfo метода, который помечен моим аттрибутом появляется NullReferenceException

NullReferenceException: Object reference not set to an instance of an object
SubEventAttribute.RegisterListeners () (at Assets/everrnet/EventSystem/SubEventAttribute.cs:16)
Loader.Awake () (at Assets/everrnet/Loader/Loader.cs:11)

Код Loader.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Loader : MonoBehaviour {
    public static SubEventAttribute SEA;
    // Start is called before the first frame update
    void Awake()
    {
        SEA = ScriptableObject.CreateInstance<SubEventAttribute>();
        SEA.RegisterListeners();
    }
}

Код Event.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Event : ScriptableObject {
    public EventType type;
    public Event EVENT;
    public Event(EventType type = EventType.POST) {
        this.type = type;
    }
}
public enum EventType { 
    PRE,
    POST
}

Код SunEventAttribute.cs

using System.Reflection;
using UnityEngine;

public class SubEventAttribute : ScriptableObject {
    public MethodInfo[] listeners;
    public void RegisterListeners() {
        MonoBehaviour[] sceneActive = FindObjectsOfType<MonoBehaviour>();
        foreach (var mono in sceneActive) {
            var methods = mono.GetType().GetMethods();            
            for (int i = 0; i < methods.Length; i++) {
                SubscribeEvent attribute = Attribute.GetCustomAttribute(methods[i], typeof(SubscribeEvent)) as SubscribeEvent;
                var m = methods[i];
                if (attribute != null && IsParameterEvent(m)) {
                    Debug.Log("Registered event subscriber in " + mono.name + " method: " + methods[i]);
                    listeners[listeners.Length + 1] = m;
                }
                else if(attribute != null) {
                    Debug.LogError("Event subscriber without \"Event\" parameter in \"" + mono.name + "\"");
                }
            }
        }
    }
    bool IsParameterEvent(MethodInfo mi) {
        try
        {
            return mi.GetParameters()[0].ParameterType.ToString() == "Event";
        }
        catch (Exception)
        {
            return false;
        }
    }
}
[AttributeUsage(AttributeTargets.Method)]
public class SubscribeEvent : Attribute {
}

Код EventStart.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EventStart : Event {
    public EventStart() {
        base.EVENT = this;
    }
}

Код ES_TEST.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ES_TEST : MonoBehaviour
{    
    [SubscribeEvent]
    public void EventSystemTest(Event e) {
        if (e.EVENT is EventStart) {
            Debug.Log("Rcved event is start type");
        } else {
            Debug.Log("Rcved event is not start type");
        }
    }
}

Ответы (0 шт):