Skip to content

3. Regular Attributes

Miłosz Matkowski edited this page Aug 28, 2024 · 6 revisions

All attributes based on built-in class - PropertyAttribute. It means they work independently to Toolbox Editor, can be used without limitation outside this package, and have priority over all Toolbox attributes. You can use only one attribute per property.

TagSelectorAttribute

Supported types: string.

[TagSelector]
public string var1;

ProgressBarAttribute

Supported types: int, float, double.

[ProgressBar("Name", minValue: 0.0f, maxValue: 100.0f, HexColor = "#EB7D34", IsInteractable = true)]
public float var1 = 80.0f;


MinMaxSliderAttribute

Supported types: Vector2.

[MinMaxSlider(0.5f, 71.7f)]
public Vector2 var1;

AssetPreviewAttribute

Supported types: any UnityEngine.Object.

[AssetPreview]
public GameObject var1;
[AssetPreview(useLabel: false)]
public Component var2;

SuffixAttribute

Supported types: all.

[Suffix("cm")]
public float var1;

EnumTogglesAttribute

Supported types: Enum.

[System.Flags]
public enum FlagExample
{
	Nothing = 0,
	Flag1 = 1,
	Flag2 = 2,
	Flag3 = 4,
	Flag4 = 8,
	Flag5 = 16,
	Flag6 = 32,
	Flag7 = 64,
	Flag8 = 128,
	Flag9 = 256,
	Everything = ~0
}

[EnumToggles]
public FlagExample enumFlag = FlagExample.Flag1 | FlagExample.Flag2 | FlagExample.Flag6;

inspector

NotNullAttribute

Supported types: any UnityEngine.Object.

[NotNull("Variable has to be assigned.")]
public Transform var1;


*This attribute will be deprecated and reimplemented as part of the Toolbox attributes.

DirectoryAttribute

Supported types: string.

[Directory]
public string var1;


SceneNameAttribute

Supported types: string.

[SceneName]
public string var1;


PresetAttribute

Supported types: all. Remark: can be used only within classes, structs are not supported.

private readonly int[] presetValues = new[] { 1, 2, 3, 4, 5 };

[Preset(nameof(presetValues))]
public int presetTarget;

SearchableEnumAttribute

Supported types: any Enum.

[SearchableEnum]
public KeyCode enumSearch;

PasswordAttribute

Supported types: string.

[Password]
public string password;

LeftToggleAttribute

Supported types: bool.

[LeftToggle]
public bool var1;

FormattedNumberAttribute

Supported types: int, float, double.

[FormattedNumber]
public int bigNumber;

LayerAttribute

Supported types: int.

[Layer]
public int var1;

ClampAttribute

Supported types: int, float, double.

[Clamp(minValue = 1.5f, maxValue = 11.3f)]
public double var1;

*This attribute will be deprecated and reimplemented as part of the Toolbox attributes.

ChildObjectOnlyAttribute

*This attribute will be deprecated and reimplemented as part of the Toolbox attributes.

SceneObjectOnlyAttribute

*This attribute will be deprecated and reimplemented as part of the Toolbox attributes.

PrefabObjectOnlyAttribute

*This attribute will be deprecated and reimplemented as part of the Toolbox attributes.

NotPrefabObjectOnlyAttribute

*This attribute will be deprecated and reimplemented as part of the Toolbox attributes.