Skip to content

3. Regular Attributes

Miłosz Matkowski edited this page Apr 30, 2022 · 8 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")]
public float var1 = 80.0f;


NewLabelAttribute

Supported types: all.

[NewLabel("Custom Label", "Element")]
public int[] vars1 = new int[3];
[NewLabel("Custom Label")]
public float var2 = 25.4f;

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

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;

HideLabelAttribute

Supported types: all.

[HideLabel]
public Camera var1;

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

Supproted 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;

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.

PasswordAttribute

Supported types: string.

[Password]
public string password;

LabelByChildAttribute

Supported types: all.

[System.Serializable]
public class SampleClass1
{
	public Material var1;
	public KeyCode var2;
	public SampleClass2 var3;
}

[System.Serializable]
public class SampleClass2
{
	public int var1;
	public string var2;
}

[LabelByChild("var2")]
public SampleClass1[] vars1;
[LabelByChild("var3.var2")]
public SampleClass1 var1;

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.

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;
Clone this wiki locally