DarkRewar / BaseTool

A big library of basic tools that you might need in your Unity projects.
MIT License
45 stars 6 forks source link

Button Attribute #18 #93

Closed DarkRewar closed 6 months ago

DarkRewar commented 6 months ago

ButtonAttribute

You can add a [Button] attribute before a method to display a button in the inspector. When clicked, it will execute the method linked to the button attribute.

using BaseTool;
using UnityEngine;

public class ButtonTest : MonoBehaviour
{
    [Button]
    public void DoSomething()
    {
        Debug.Log("Method called from inspector");
    }
}

button_attribute