mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
simple refactoring
This commit is contained in:
parent
f8c95fbd98
commit
762ba241da
@ -1,7 +1,9 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditor.UI;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS.Editors
|
namespace DCFApixels.DragonECS.Editors
|
||||||
@ -136,5 +138,18 @@ namespace DCFApixels.DragonECS.Editors
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ReflectionExtensions
|
||||||
|
{
|
||||||
|
public static bool TryGetAttribute<T>(this MemberInfo self, out T attrbiute) where T : Attribute
|
||||||
|
{
|
||||||
|
attrbiute = self.GetCustomAttribute<T>();
|
||||||
|
return attrbiute != null;
|
||||||
|
}
|
||||||
|
public static bool HasAttribute<T>(this MemberInfo self) where T : Attribute
|
||||||
|
{
|
||||||
|
return self.GetCustomAttribute<T>() != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -134,7 +134,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (t.IsSubclassOf(typeof(TemplateComponentInitializer<>)))
|
if (t.IsSubclassOf(typeof(TemplateComponentInitializer<>)))
|
||||||
{
|
{
|
||||||
if (t.GetCustomAttribute<SerializableAttribute>() != null)
|
if (t.HasAttribute<SerializableAttribute>())
|
||||||
types.Add(t);
|
types.Add(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user