您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
41 行
1.1 KiB
41 行
1.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace GameplayIngredients
|
|
{
|
|
public static class TypeUtility
|
|
{
|
|
public static Type[] GetConcreteTypes<T>()
|
|
{
|
|
List<Type> types = new List<Type>();
|
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
|
{
|
|
Type[] assemblyTypes = null;
|
|
|
|
try
|
|
{
|
|
assemblyTypes = assembly.GetTypes();
|
|
}
|
|
catch
|
|
{
|
|
Debug.LogError($"Could not load types from assembly : {assembly.FullName}");
|
|
}
|
|
|
|
if (assemblyTypes != null)
|
|
{
|
|
foreach (Type t in assemblyTypes)
|
|
{
|
|
if (typeof(T).IsAssignableFrom(t) && !t.IsAbstract)
|
|
{
|
|
types.Add(t);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return types.ToArray();
|
|
}
|
|
}
|
|
|
|
}
|