All Projects → madsbangh → Easybuttons

madsbangh / Easybuttons

Licence: mit
Add buttons to your inspector in Unity super easily with this simple attribute

Projects that are alternatives of or similar to Easybuttons

Tracerysharp
C#/Unity port of Tracery (heavily WIP)
Stars: ✭ 19 (-95.37%)
Mutual labels:  unity, unity3d, unity-editor
Uniuguitoolbar
【Unity】uGUI のオブジェクトを作成できるツールバーのエディタ拡張
Stars: ✭ 44 (-89.27%)
Mutual labels:  unity, unity3d, unity-editor
Unitynativescripting
Unity Scripting in C++
Stars: ✭ 844 (+105.85%)
Mutual labels:  unity, unity3d, unity-editor
Texture maker
A texture maker tool for unity.
Stars: ✭ 358 (-12.68%)
Mutual labels:  unity, unity3d, unity-editor
Ma textureatlasser
Texture atlas creator for Unity
Stars: ✭ 116 (-71.71%)
Mutual labels:  unity, unity3d, unity-editor
Actors.unity
🚀Actors is a framework empowering developers to make better games faster on Unity.
Stars: ✭ 437 (+6.59%)
Mutual labels:  unity, unity3d, unity-editor
Scene View Bookmarks
Unity editor extension to bookmark scene views.
Stars: ✭ 40 (-90.24%)
Mutual labels:  unity, unity3d, unity-editor
Unity Assetpipeline Presentation
Unity project for "A Technical Deep-Dive into Unity's Asset Pipeline" presented at Develop: 2018
Stars: ✭ 31 (-92.44%)
Mutual labels:  unity, unity3d, unity-editor
Pb stl
STL import/export for Unity, supporting both ASCII and Binary.
Stars: ✭ 108 (-73.66%)
Mutual labels:  unity, unity3d, unity-editor
Extosc
extOSC is a tool dedicated to simplify creation of applications in Unity with OSC protocol usage.
Stars: ✭ 69 (-83.17%)
Mutual labels:  unity, unity3d, unity-editor
Awesome Unity Open Source On Github
A categorized collection of awesome Unity open source on GitHub (800+)
Stars: ✭ 1,124 (+174.15%)
Mutual labels:  unity, unity3d, unity-editor
Unity Editor Toolbox
Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.
Stars: ✭ 273 (-33.41%)
Mutual labels:  unity, unity3d, unity-editor
Unitypausemenu
This is an open source Unity pause menu created for the game New Horizons, and it's completely free because of how a pause menu is a core component of a game, while the unity asset store was lacking in such an asset (until this was released on the asset store).
Stars: ✭ 160 (-60.98%)
Mutual labels:  unity, unity3d, unity-editor
Unity Script Collection
A maintained collection of useful & free unity scripts / library's / plugins and extensions
Stars: ✭ 3,640 (+787.8%)
Mutual labels:  unity, unity3d, unity-editor
Opencvforunity
OpenCV for Unity (Untiy Asset Plugin)
Stars: ✭ 359 (-12.44%)
Mutual labels:  unity, unity3d
Klakndi
NewTek NDI™ plugin for Unity
Stars: ✭ 401 (-2.2%)
Mutual labels:  unity, unity3d
Starforce
This is a demo made with Game Framework.
Stars: ✭ 375 (-8.54%)
Mutual labels:  unity, unity3d
Game Networking Resources
A Curated List of Game Network Programming Resources
Stars: ✭ 4,208 (+926.34%)
Mutual labels:  unity, unity3d
Unity Shadersketches
Sketches made with ShaderLab in Unity.
Stars: ✭ 362 (-11.71%)
Mutual labels:  unity, unity3d
Akvfx
Azure Kinect plugin for Unity VFX Graph
Stars: ✭ 366 (-10.73%)
Mutual labels:  unity, unity3d

Easy buttons for the Unity default inspector

openupm

These tiny scripts add the ability to quickly show a button in the inspector for any method.

Installation

OpenUPM

Once you have the OpenUPM cli, run the following command:

openupm install com.madsbangh.easybuttons

Or if you don't have it, add the scoped registry to manifest.json with the desired version:

  "scopedRegistries": [
    {
      "name": "package.openupm.com",
      "url": "https://package.openupm.com",
      "scopes": [
        "com.madsbangh.easybuttons",
        "com.openupm"
      ]
    }
  ],
  "dependencies": {
    "com.madsbangh.easybuttons": "1.2.0"
  }

Git URL

Project supports Unity Package Manager. To install the project as a Git package do the following:

  1. In Unity, open Window -> Package Manager.
  2. Press the + button, choose "Add package from git URL..."
  3. Enter "https://github.com/madsbangh/EasyButtons.git#upm" and press Add.

Unity Package

Alternatively, you can add the code directly to the project:

  1. Clone the repo or download the latest release.
  2. Add the EasyButtons folder to your Unity project or import the .unitypackage

How To Use

  1. Add the Button attribute to a method.

    using EasyButtons; // 1. Import the namespace
    using UnityEngine;
    
    public class ButtonsExample : MonoBehaviour
    {
        // 2. Add the Button attribute to any method.
    	[Button]
    	public void SayHello()
        {
            Debug.Log("Hello");
        }
    }
    
  2. You should now see a button at the top of the component with the same name as the method:

    Button in the inspector

    Result

  3. Add the Button attribute to a method with parameters.

    using EasyButtons;
    using UnityEngine;
    
    public class Test : MonoBehaviour
    {
        [Button]
        public void ButtonWithParameters(string message, int number)
        {
            Debug.Log($"Your message #{number}: '{message}'");
        }
    }
    
  4. You can now enter parameter values and invoke the method in the inspector:

    Button with parameters

Attribute Options

The Button attribute has different options that allow customizing the button look.

Mode - indicates when the button is enabled. You can choose between the following options:

  • AlwaysEnabled - the button is enabled in edit mode and play mode.

  • EnabledInPlayMode - the button is only enabled in play mode.

  • DisabledInPlayMode - the button is only enabled in edit mode.

Spacing - allows to have some space before or after the button. The following options can be used:

  • None - no spacing at all.

  • Before - adds space above the button.

  • After - adds space below the button.

Expanded - whether to expand the parameters foldout by default. It only works with buttons that have parameters.

Custom Editors

If you want to show buttons in a custom editor, you can use the ButtonsDrawer class defined in EasyButtons.Editor.

Instantiate ButtonsDrawer in OnEnable if possible, then draw the buttons with help of the DrawButtons method, as in the example:

[CustomEditor(typeof(Example))]
public class CustomEditor : ObjectEditor
{   
    private ButtonsDrawer _buttonsDrawer;

    private void OnEnable()
    {
        _buttonsDrawer = new ButtonsDrawer(target);
    }

    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        _buttonsDrawer.DrawButtons(targets);
    }
}

You can also draw only specific buttons:

// Draw only the button called "Custom Editor Example"
_buttonsDrawers.Buttons.First(button => button.DisplayName == "Custom Editor Example").Draw(targets);

You can search for a specific button using its DisplayName or Method (MethodInfo object the button is attached to.)

Notes

  • Older versions of Unity might not understand the reference to EasyButtons runtime in the EasyButtons editor assembly definition. If you experience issues, you can re-add the reference, or remove the asmdefs completely.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].