25 lines
736 B
C#
25 lines
736 B
C#
using System.Reflection;
|
|
using UnityEngine;
|
|
|
|
namespace Module.Inspector.Editor
|
|
{
|
|
[CustomMethodDrawer(typeof(MethodButton))]
|
|
internal sealed class DrawerMethodButton : DrawerMethodDrawer
|
|
{
|
|
public override bool Draw(Rect position, DrawerMethodAttribute attribute, Object target, MethodInfo methodInfo)
|
|
{
|
|
var att = (MethodButton)attribute;
|
|
string name = string.IsNullOrEmpty(att.name) ? methodInfo.Name : att.name;
|
|
|
|
if (GUI.Button(position, name))
|
|
methodInfo.Invoke(methodInfo.IsStatic ? null : target, null);
|
|
|
|
return true;
|
|
}
|
|
|
|
public override string GetErrorMessage()
|
|
{
|
|
return string.Empty;
|
|
}
|
|
}
|
|
} |