using System; using System.Reflection; using System.Linq; using System.Collections; using System.Collections.Generic; using UnityEngine; public static class ReflectiveEnumerator { static ReflectiveEnumerator() { } public static IEnumerable GetEnumerableOfType(params object[] constructorArgs) where T : class, IComparable { List objects = new List(); var assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in assemblies) { foreach (Type type in assembly.GetTypes() .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T)))) { objects.Add((T)Activator.CreateInstance(type, constructorArgs)); } } //foreach (var item in objects) Debug.Log(item); objects.Sort((x,y) => String.Compare(x.ToString(), y.ToString())); //objects.Sort(); return objects; } }