using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEditor; using UnityEngine; namespace Needle.Engine.Utils { public static class InstanceCreatorUtil { public static List CreateCollectionSortedByPriority() { var res = new List(); #if UNITY_EDITOR var types = TypeCache.GetTypesDerivedFrom() .OrderByDescending(e => e.GetCustomAttribute()?.Value ?? 0) .Where(e => !e.IsAbstract && !e.IsInterface); foreach (var type in types) { if (typeof(Component).IsAssignableFrom(type)) continue; res.Add((T)Activator.CreateInstance(type)); } #endif return res; } } }