HAARFTE/Assets/DemoGame/GameScript/Hotfix/UI/AssemblyManager.cs

30 lines
819 B
C#

using System;
using System.Collections.Generic;
using Sirenix.Utilities;
namespace ZC
{
public static class AssemblyManager
{
private static List<Type> _types;
public static void Initialize()
{
var types = typeof(AssemblyManager).Assembly.GetTypes();
_types = new List<Type>(types);
}
public static void GetTypesInhertType<T>(Type baseType, List<(Type, T)> types) where T : Attribute
{
foreach (var type in _types)
{
if (!baseType.IsAssignableFrom(type))
continue;
var attribute = type.GetCustomAttribute<T>();
if (attribute == null)
continue;
types.Add((type, attribute));
}
}
}
}