DarkRewar / BaseTool

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

Button Attribute #18 #93

Closed DarkRewar closed 4 months ago

DarkRewar commented 4 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