mirror of
https://github.com/AnnulusGames/Alchemy.git
synced 2025-01-22 08:18:51 -05:00
Add: LabelText argument for Button attribute
This commit is contained in:
parent
bcaeef5ea9
commit
879aa3db25
@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using Alchemy.Inspector;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
@ -17,7 +18,7 @@ namespace Alchemy.Editor.Elements
|
||||
{
|
||||
button = new Button(() => methodInfo.Invoke(target, null))
|
||||
{
|
||||
text = methodInfo.Name
|
||||
text = methodInfo.GetCustomAttribute<ButtonAttribute>().LabelText ?? methodInfo.Name
|
||||
};
|
||||
Add(button);
|
||||
return;
|
||||
@ -30,7 +31,7 @@ namespace Alchemy.Editor.Elements
|
||||
|
||||
foldout = new Foldout()
|
||||
{
|
||||
text = methodInfo.Name,
|
||||
text = methodInfo.GetCustomAttribute<ButtonAttribute>().LabelText ?? methodInfo.Name,
|
||||
value = false,
|
||||
style = {
|
||||
flexGrow = 1f
|
||||
|
@ -18,7 +18,12 @@ namespace Alchemy.Inspector
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class ButtonAttribute : Attribute { }
|
||||
public sealed class ButtonAttribute : Attribute
|
||||
{
|
||||
public ButtonAttribute() => LabelText = null;
|
||||
public ButtonAttribute(string labelText) => LabelText = labelText;
|
||||
public string LabelText { get; }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public sealed class ShowInInspectorAttribute : Attribute { }
|
||||
|
Loading…
Reference in New Issue
Block a user