Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: LabelText argument for Button attribute #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yuyu0127
Copy link
Contributor

@yuyu0127 yuyu0127 commented Mar 16, 2024

I added support for the label argument in the ButtonAttribute supported in Odin Inspector and NaughtyAttributes.
This works as follows:

image
using System.Text;
using UnityEngine;
using Alchemy.Inspector;

namespace Alchemy.Samples
{
    public class ButtonSample : MonoBehaviour
    {
        [Button("Label for Foo()")]
        public void Foo()
        {
            Debug.Log("Foo");
        }

        [Button("Label for Foo(int)")]
        public void Foo(int parameter)
        {
            Debug.Log("Foo: " + parameter);
        }

        [Button("Label for Foo(SampleClass)")]
        public void Foo(SampleClass parameter)
        {
            var builder = new StringBuilder();
            builder.AppendLine();
            builder.Append("foo = ").AppendLine(parameter.foo.ToString());
            builder.Append("bar = ").AppendLine(parameter.bar.ToString());
            builder.Append("baz = ").Append(parameter.baz == null ? "Null" : parameter.baz.ToString());
            Debug.Log("Foo: " + builder.ToString());
        }
    }
}

@yuyu0127 yuyu0127 force-pushed the button-label-text-argument branch from e9d31e8 to 879aa3d Compare March 16, 2024 15:22
@yn01dev
Copy link
Owner

yn01dev commented Mar 21, 2024

Perhaps this could be substituted with the LabelText attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants