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 with Button support #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MrBelarus
Copy link

I added support for Button label change with LabelText attribute.
Updated ButtonSample.cs and in inspector it looks like this:

image

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

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

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

        [Button, LabelText("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());
        }
    }
}

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.

1 participant