mirror of
https://github.com/AnnulusGames/Alchemy.git
synced 2025-01-22 08:18:51 -05:00
Add: OnInspectorDestroyAttribute
This commit is contained in:
parent
8e0d608191
commit
2401642ac8
@ -28,10 +28,10 @@ namespace Alchemy.Editor
|
||||
{
|
||||
foreach (var target in targets)
|
||||
{
|
||||
foreach (var onEnableMethod in ReflectionHelper.GetAllMethodsIncludingBaseNonPublic(target.GetType())
|
||||
foreach (var method in ReflectionHelper.GetAllMethodsIncludingBaseNonPublic(target.GetType())
|
||||
.Where(x => x.HasCustomAttribute<OnInspectorEnableAttribute>()))
|
||||
{
|
||||
onEnableMethod.Invoke(target, null);
|
||||
method.Invoke(target, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,10 +40,22 @@ namespace Alchemy.Editor
|
||||
{
|
||||
foreach (var target in targets)
|
||||
{
|
||||
foreach (var onEnableMethod in ReflectionHelper.GetAllMethodsIncludingBaseNonPublic(target.GetType())
|
||||
foreach (var method in ReflectionHelper.GetAllMethodsIncludingBaseNonPublic(target.GetType())
|
||||
.Where(x => x.HasCustomAttribute<OnInspectorDisableAttribute>()))
|
||||
{
|
||||
onEnableMethod.Invoke(target, null);
|
||||
method.Invoke(target, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
foreach (var target in targets)
|
||||
{
|
||||
foreach (var method in ReflectionHelper.GetAllMethodsIncludingBaseNonPublic(target.GetType())
|
||||
.Where(x => x.HasCustomAttribute<OnInspectorDestroyAttribute>()))
|
||||
{
|
||||
method.Invoke(target, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,4 +194,7 @@ namespace Alchemy.Inspector
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class OnInspectorDisableAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class OnInspectorDestroyAttribute : Attribute { }
|
||||
}
|
Loading…
Reference in New Issue
Block a user