using UnityEngine; using System.Collections.Generic; public abstract class ListComponent : MonoBehaviour where T : MonoBehaviour { public static List InstanceList = new List(); protected virtual void OnEnable() { InstanceList.Add( this as T ); } protected virtual void OnDisable() { InstanceList.Remove( this as T ); } }