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

Variable aspect

PreviousDecoratorsNextButtons

Last updated 1 year ago

SetIcon

Displays an icon at the left of the variable.

Supported property types

Everything.

Parameters

  • IconPath

  • IconSize

Code Example

using UltimateAttributesPack;

public class SetIconExample : MonoBehaviour
    {
        // SetIcon attribute displays an icon at the left of the variable
        [SetIcon("Assets/UltimateAttributesPack/Examples/Assets/Icons/PenIcon.png")]
        public string stringValue;

        // You can also change the icon size (small, medium or large)
        [SetIcon("Assets/UltimateAttributesPack/Examples/Assets/Icons/PenIcon.png", IconSize.Large)]
        public string secondStringValue;
    }

ChangeColor

Change the color of the variable (text or/and background).

Supported property types

Everything.

Parameters

  • TextColor

  • BackgroundColor

Code Example

using UltimateAttributesPack;

public class ChangeColorExample : MonoBehaviour
    {
        // You can change the text color and the background color of the variable
        [ChangeColor("red", "orange")]
        public string stringValue;

        // It also works hexadecimal
        [ChangeColor("C2E7FF", "444746")]
        public float floatValue;
    }

ChangeLabel

Change the label of the variable.

Supported property types

Everything.

Parameters

  • NewLabel

Code Example

using UltimateAttributesPack;

public class ChangeLabelExample : MonoBehaviour
    {
        // ChangeLabel attribute change the label of the variable in the inspector.
        [ChangeLabel("New Label")]
        public string stringValue; // The variable name is "stringValue" but the label displayed in the inspector is "New Label"
    }

Indent

Indent the variable to a target level in the inspector.

Supported property types

Everything.

Parameters

  • IndentLevel

Code Example

using UltimateAttributesPack;

public class IndentExample : MonoBehaviour
    {
        public string stringValue;

        // Indent attribute can be used to indent the variable to a specific level in the inspector
        [Indent(2)]
        public float floatValue;

        [Indent(4)]
        public float intValue;
    }

Prefix

Displays a prefix text at the left of the variable in the inspector.

Supported property types

Everything.

Parameters

  • PrefixText

Code Example

using UltimateAttributesPack;

public class PrefixExample : MonoBehaviour
    {
        // Prefix attribute displays a prefix text at the left of the variable
        [Prefix("Prefix")]
        public string stringValue;
    }

Suffix

Displays a suffix text at the right of the variable in the inspector.

Supported property types

Everything.

Parameters

  • SuffixText

Code Example

using UltimateAttributesPack;

public class SuffixExample : MonoBehaviour
    {
        // Suffix attribute displays a suffix text at the right of the variable
        [Suffix("Suffix")]
        public string stringValue;
    }

ReadOnly

Displays the variable in read only in the inspector.

Supported property types

Everything.

Parameters

None.

Code Example

using UltimateAttributesPack;

public class ReadOnlyExample : MonoBehaviour
    {
        // It shows the variable in readonly in the inspector
        [ReadOnly]
        public float floatValue;
    }
MinMaxSlider

Displays a MinMaxSlider for Vector2 or Vector2Int in the inspector.

Supported property types

  • Vector2

  • Vector2Int

Parameters

  • Min

  • Max

Code Example

using UltimateAttributesPack;

public class MinMaxSliderExample : MonoBehaviour
    {
        // MinMaxSliders are principally used to randomize between a min and a max values

        // You can use it on vector2
        [MinMaxSlider(0, 100)]
        public Vector2 vector2;

        // You can also use it on vector2Int
        [MinMaxSlider(0, 100)]
        public Vector2Int vector2Int;
    }
ProgressBar

Displays a progress bar in the inspector with min and max values, and based on variable value.

Supported property types

  • Float

  • Int

Parameters

  • Text

  • Min

  • Max

  • DisplayPercent

Code Example

using UltimateAttributesPack;

public class ProgressBarExample : MonoBehaviour
    {
        // To change the progress bar value, you can use the FunctionButton attribute
        [FunctionButton("Reset progress bar value", "ResetProgressBar", typeof(ProgressBarExample))]

        // You can also use the DoOnValueChanged attribute
        [DoOnValueChanged("SetProgressBar", typeof(ProgressBarExample))]
        public float currentValue;

        // You can use it to display a bar on the inspector to visualize the value between a min and a max
        [ProgressBar("Float value", 0, 100)]
        public float floatProgressBar;

        // You can also display the current percent of the value on the title
        [ProgressBar("Int value", 0, 100, true)]
        public int intProgressBar;

        void SetProgressBar()
        {
            floatProgressBar = currentValue;
            intProgressBar = Mathf.RoundToInt(currentValue);
        }

        void ResetProgressBar()
        {
            currentValue = 0;
            floatProgressBar = 0;
            intProgressBar = 0;
        }
    }