Attributes

Attributes are used to attach metadata to defined properties, similar to Decorator in scripting languages or Attribute in C#.

Related Attributes on Inspector Panel

Attribute NameDescriptionTypeDefaultRemarks
typeRestrict the data type of the property(Any)undefinedSee type attribute
visibleShow or hide in the Inspector panelboolean[1]See visible attribute
displayNameShow as another name in the Inspector panelstringundefined-
tooltipAdd a Tooltip for a property in the Inspector panelstringundefined-
multilineUse multi-line text boxes in the Inspector panelbooleanfalse-
readonlyRead-only in the Inspector panelbooleanfalse-
minRestrict the minimum value in the Inspector panelnumberundefined-
maxRestrict the maximum value in the Inspector panelnumberundefined-
stepRestrict the step value in the Inspector panelnumberundefined-
rangeSet min, max, step[min, max, step]undefinedstep value optional
slideShow as a slider in the Inspector panelbooleanfalse-

Serialization-Related Attributes

The following attributes cannot be used with the get method.

Attribute NameDescriptionTypeDefaultRemarks
serializableSerialize this propertybooleantrueSee serializable attribute
formerlySerializedAsSpecify the name of the field used in the previous serializationstringundefinedDeclare this attribute when renaming the property to be compatible with the previously serialized data
editorOnlyExclude this property before exporting the projectbooleanfalse-

Other Attributes

Attribute NameDescriptionTypeDefaultRemarks
defaultDefine the default value of an attribute(Any)undefinedSee default attribute
notifyTrigger the specified method when the property is assigned a valuefunction (oldValue) {}undefinedThe default attribute needs to be set and its value cannot be an array.
Not support ES6 definitions
overrideDefine this parameter as true when overriding parent propertiesbooleanfalseSee override parameter
animatableWhether this property can be modified by the animation editorbooleanundefined-

[1]: The default value of visible depends on the property name. When the property name starts with an underscore _, it is hidden by default, otherwise it is shown by default.