Skip to main content
Version: 🚧 Work in Progress

Units Attribute

The Units attribute allows you to easily display the units for a serialized field in the inspector. This attribute can be used on both Jungle nodes and Unity objects.

MAY BREAK ON SOME FIELDS

The Units attribute adds a label next to the serialized fields property drawer in the inspector. Some large or complex property drawers may break when the Unit attribute is used.

Overview​

The Units attribute provides the following functionality:

  • Displays units in the inspector on the given serialized fields property drawer.

How to Use​

  • Step 1: Import the Jungle.Extensions namespace at the top of your script.
  • Step 2: Add the attribute to any fields you'd like to have units in the inspector.

Example​

This node's inspector will contain three fields with units on each.

using Jungle;
using Jungle.Extensions;
using UnityEngine;

public class MyNodeWithUnits : IdentityNode
{
[SerializeField]
[Units("Second(s)")]
private float fadeDuration = 1f;

[SerializeField]
[Units("ms")]
private float responseTime = 0.025f;

[SerializeField]
[Units("Frame(s)")]
private int frameDelay = 5;

...
}

Units Attribute Example