using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System;
using System.Linq;
public class ReflectionEditor : Editor
{
#region 继承链
[MenuItem("Reflection/向上的继承链")]
static void 向上的继承链()
{
for (int i = 0; i < Selection.objects.Length; i++)
{
var monoScript = Selection.objects[i] as MonoScript;
if (monoScript == null)
continue;
var type = monoScript.GetClass();
Debug.Log(type + " 向上的继承链 : ");
IEnumerable<Type> types = type.Assembly.GetTypes().Where(item => item.IsAssignableFrom(type) && item != type);
foreach (Type t in types)
Debug.Log(t);
}
}
[MenuItem("Reflection/向下的继承链")]
static void 向下的继承链()
{
for(int i = 0; i < Selection.objects.Length; i++)
{
var monoScript = Selection.objects[i] as MonoScript;
if (monoScript == null)
continue;
var type = monoScript.GetClass();
Debug.Log(type + " 向下的继承链 : ");
IEnumerable<Type> types = type.Assembly.GetTypes().Where(item => type.IsAssignableFrom(item) && item != type);
foreach (Type t in types)
Debug.Log(t);
}
}
#endregion
}
using System.Collections.Generic;
using UnityEditor;
using System;
using System.Linq;
public class ReflectionEditor : Editor
{
#region 继承链
[MenuItem("Reflection/向上的继承链")]
static void 向上的继承链()
{
for (int i = 0; i < Selection.objects.Length; i++)
{
var monoScript = Selection.objects[i] as MonoScript;
if (monoScript == null)
continue;
var type = monoScript.GetClass();
Debug.Log(type + " 向上的继承链 : ");
IEnumerable<Type> types = type.Assembly.GetTypes().Where(item => item.IsAssignableFrom(type) && item != type);
foreach (Type t in types)
Debug.Log(t);
}
}
[MenuItem("Reflection/向下的继承链")]
static void 向下的继承链()
{
for(int i = 0; i < Selection.objects.Length; i++)
{
var monoScript = Selection.objects[i] as MonoScript;
if (monoScript == null)
continue;
var type = monoScript.GetClass();
Debug.Log(type + " 向下的继承链 : ");
IEnumerable<Type> types = type.Assembly.GetTypes().Where(item => type.IsAssignableFrom(item) && item != type);
foreach (Type t in types)
Debug.Log(t);
}
}
#endregion
}