🗒️
Ultimate Attributes Pack
  • Introduction
  • Decorators
  • Variable aspect
  • Buttons
  • Folded infos
  • Conditionals
  • Validators
  • Component getters
  • Popups
Powered by GitBook
On this page

Buttons

PreviousVariable aspectNextFolded infos

Last updated 1 year ago

FunctionButton

Displays a button in the inspector that execute a function without parameters when clicked.

Supported property types

Everything.

Parameters

  • Text

  • FunctionName

  • ClassType

Code Example

using UltimateAttributesPack;

public class FunctionButtonExample : MonoBehaviour
    {
        // You can use it to execute a function of the script in editor or play mode
        [FunctionButton("Click to log a message in console", "LogMessage", typeof(FunctionButtonExample))]
        public float floatValue;

        [FunctionButton("Click to increment value", "IncrementValue", typeof(FunctionButtonExample))]
        public int intValue;

        // You can also use it to call a function on another script of the object
        [FunctionButton("Click to log a message from another script of the object", "LogMessageOfOtherScript", typeof(DoOnValueChangedExample))]
        public string stringValue;

        void LogMessage()
        {
            Debug.Log("This is a message in the console");
        }

        void IncrementValue()
        {
            intValue++;
        }
    }

OpenFolderButton

Displays a button in the inspector that open a specific project folder when clicked.

Supported property types

Everything.

Parameters

  • Text

  • FolderPath

Code Example

using UltimateAttributesPack;

public class OpenFolderButtonExample : MonoBehaviour
    {
        // You can use it to open a specific folder of the project
        [OpenFolderButton("Click to open the UltimateAttributesPack root folder", "Assets/UltimateAttributesPack")]
        public float floatValue;
    }

OpenInternetPageButton

Displays a button in the inspector that open a specific internet page when clicked.

Supported property types

Everything.

Parameters

  • Text

  • Link

Code Example

using UltimateAttributesPack;

public class OpenInternetPageButtonExample : MonoBehaviour
    {
        // You can use it in different ways, like redirecting to an online documentation or a specific video
        [OpenInternetPageButton("Click to open a specific internet page", "https://assetstore.unity.com/")]
        public float floatValue;
    }

RandomizeButton

Displays a button at the right of the variable in the inspector that randomize it between a minimum, a maximum and a digits count when clicked.

Supported property types

  • Float

  • Int

Parameters

  • MinValue

  • MaxValue

  • Digits

Code Example

using UltimateAttributesPack;

public class RandomizeButtonExample : MonoBehaviour
    {
        // RandomizeButton attribute displays a button at the right of the variable to randomize the value between a min and a max and with a digits count
        // Digits count have a maximum of 5
        [RandomizeButton(0, 100, 3)]
        public float floatValue;

        // It also works with int
        [RandomizeButton(-50, 50, 0)]
        public int intValue;
    }

AddSubtractButtons

Displays two buttons in the inspector that add and subtract defined values to the variable when clicked.

Supported property types

  • Float

  • Int

Parameters

  • SubtractValue

  • AddValue

Code Example

using UltimateAttributesPack;

public class AddSubtractButtonsExample : MonoBehaviour
    {
        // AddSubtractButtons attribute displays buttons at the right of the variable to add of subtract it with specific values
        [AddSubtractButtons(1, 1)]
        public int intValue;

        // It also works with float values
        [AddSubtractButtons(2.5f, 2.5f)]
        public float floatValue;
    }