Skip to content

jfranmora/unity-inspector-button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[Unity] Inspector Extensions - Button

Add a button in inspector to call functions. A substitute for [ContextMenu()]

Example

Installation (Manual)

Download the latest release and unzip it in the project.

Installation (UPM)

Add to manifest.json as dependency the following line:

"com.jfranmora.inspector.button": "https://github.com/jfranmora/unity-inspector-button.git#upm"

How to use

Add the [Button] attribute to a function. Optionally, you can set HideInEditMode or HideInPlayMode to hide the button in Editor Mode or Play Mode.

public class Example : MonoBehaviour
{
    public float value = 0;

    [Button]
    private void SomeFunction()
    {
        Debug.Log("A");
    }

    [Button(HideInEditMode = true)]
    private void EditorModeOnlyFunction()
    {
        Debug.Log("B");
    }

    [Button(HideInPlayMode = true)]
    private void PlayModeOnlyFunction()
    {
        Debug.Log("C");
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages