Annotations
Package: godot.annotation. These annotations have runtime retention and can also target annotation declarations. An annotation never makes an invalid declaration or unsupported type valid.
Registration annotations
Member examples belong inside a registered script class. All examples include the direct selection annotations needed by Explicit mode unless stated otherwise.
@Emit
Targets: property or field. parameters is an array of strings, default empty; provide one name per signal argument when naming them.
Inferred recognizes typed signals without this annotation. Explicit requires direct @Emit. Automatic selects public typed signals. The annotation names arguments; the signal name comes from the member. See signal registration.
@Export
Targets: property or field. No arguments.
Carries @Storage, so it also registers and stores the property in every mode. Automatic: a registered property is already exported unless @Visible or @Storage is written on it; written alongside them, @Export still wins. Adds Inspector visibility; it does not add a setter to a read-only property.
@Notification
Target: function. value is a required Long annotation argument. Registration converts it to a signed 32-bit notification ID; values outside that range are truncated. Use Godot notification constants.
Selects a notification handler in every mode without an additional @Register. The method must be public, take no arguments, return no result, and have no RPC configuration. It is registered as a notification handler rather than an ordinary callable method.
@Register
Target: function. No arguments.
Selects an ordinary method in Inferred and Explicit modes. Automatic already selects compatible public methods; @Register also disambiguates accessor-shaped methods. Explicit mode requires it on Godot overrides. Method names are converted to snake_case.
@Rpc
Target: function. Configures a registered method for RPC. Inferred: implies @Register. Explicit: add direct @Register. Automatic: configures a selected compatible method. A notification handler cannot also be an RPC function.
| Argument |
Type |
Default |
Values |
rpcMode |
RpcMode |
AUTHORITY |
DISABLED, ANY, AUTHORITY |
sync |
Sync |
NO_SYNC |
SYNC, NO_SYNC |
transferMode |
TransferMode |
RELIABLE |
RELIABLE, UNRELIABLE, UNRELIABLE_ORDERED |
transferChannel |
32-bit integer |
0 |
Channel index passed to Godot |
RpcMode.DISABLED disables remote calls; ANY permits any peer to call; AUTHORITY restricts calls to the multiplayer authority. Sync.SYNC includes local execution (call_local); NO_SYNC is remote-only (call_remote). RELIABLE requests reliable ordered delivery; UNRELIABLE does not guarantee delivery/order; UNRELIABLE_ORDERED discards out-of-order packets.
The registrar warns when a nonzero transferChannel is used with a mode other than UNRELIABLE_ORDERED; the channel remains part of the emitted configuration. Actual transport behavior is supplied by Godot's multiplayer peer. See Godot RPC semantics.
@Script
Target: class. className is a string, default "" (use the simple JVM class name).
Inferred accepts direct or implied @Script. Explicit requires direct @Script. Automatic selects public compatible subclasses without it; the annotation can still set a custom name. The class must derive from a Godot class.
The custom name is the base name before the configured naming policy adds a package/project prefix and sanitizes it.
@Storage
Targets: property or field. No arguments.
Carries @Visible, so it also registers the property in every mode. Automatic: replaces the assumed @Export, so a registered property is stored but hidden. The value is saved and loaded with the scene or resource but does not appear in the Inspector, like GDScript's @export_storage. With @Export on the same property, the property is exported.
Target: class. No arguments. Editor-time tool execution is not implemented.
Inferred: implies @Script. Explicit: add direct @Script. Automatic: the public compatible class is already selected. The annotation does not currently make the script run as a Godot editor tool.
@Visible
Targets: property or field. No arguments.
Registers a property without storing it or exporting it to the Inspector. Add @Storage or @Export for more. Automatic assumes @Export on every candidate property; writing @Visible replaces that default, so the property is registered but neither stored nor shown in the Inspector.
All registration and hint annotations can annotate another annotation declaration. Every mode follows these chains recursively for declaration selection and registration configuration. The built-in chains are @Export to @Storage to @Visible, property hints to @Export, @Rpc and @Notification to @Register, and @Tool to @Script. Custom annotations must be retained in the compiled class for registration to see them.
Inspector hints are read only from annotations placed directly on the property. A custom annotation carrying @FloatRange, for example, implies selection and export, but does not transfer its range hint. Place @FloatRange directly on the property to apply the range.
Property hints
Targets: property, field, or annotation declaration. Each hint carries @Export, so a hint alone registers and exports the property in every mode.
At most one property hint is allowed, including hints inferred from enum/bitfield types. A hint/type mismatch fails registration validation. Import the shown annotations from godot.annotation.
Range hints accept Int, Long, Float, or Double properties. Choose the annotation with argument precision appropriate to the property. Boolean, Byte, and Short properties are not accepted by range-hint validation.
@ColorNoAlpha
No arguments. Removes alpha editing from the color picker. Import godot.core.Color.
@Dir
global: boolean, default false. false selects a project directory; true selects a filesystem directory.
@ExpEasing
attenuation: boolean, default false; flips the curve when enabled. isPositiveOnly: boolean, default true; restricts editing to positive values.
@File
extensions: array of strings, default empty. Each string is a filter pattern. global: boolean, default false; enables filesystem paths instead of project paths.
@FloatRange
min, max: required double-precision numbers. step: double, default -1.0. Also accepts every shared range argument.
@HintString
value: required string. Replaces the generated hint string; does not choose a different Godot hint type. Use the format expected by that property's hint type.
@IntFlag
names: required array of flag labels (may be empty). Label positions correspond to bits. For enum-backed flags use BitField<E> instead.
@IntRange
min, max: required 64-bit integers. step: integer, default -1. Also accepts every shared range argument.
@MultilineText
No arguments. Uses a multiline string input.
@PlaceHolderText
No arguments. Sets Godot's placeholder-text hint. It has no text parameter, so the generated placeholder string is empty. Preserve the exact spelling PlaceHolderText.
Shared range arguments
IntRange and FloatRange accept these arguments after min, max, and step:
| Argument |
Type |
Default |
Effect in the Godot hint string |
or |
Range |
Range.NONE |
OR_GREATER adds or_greater; OR_LESSER adds or_lesser; NONE adds neither |
hideSlider |
boolean |
false |
Adds hide_slider |
isRadians |
boolean |
false |
Adds radians |
isDegrees |
boolean |
false |
Adds degrees |
isExp |
boolean |
false |
Adds exp |
suffix |
string |
"<none>" |
Adds suffix:<value> unless it equals the default sentinel |
A negative step is omitted from the generated hint. Godot interprets the resulting hint tokens. The annotations configure Inspector editing; they do not clamp assignments made by JVM code.
Inspector groups
Use @Category, @Group, and @Subgroup on the first property in a section. A category is the top-level section, a group is within a category, and a subgroup is within a group. They create Inspector markers before the annotated property; they do not change its type hint.
| Annotation |
Parameters |
@Category(name) |
name: the category label shown in the Inspector. |
@Group(name, prefix = "") |
name: the group label. prefix: optional filter for following properties whose Godot names start with it; when omitted, it defaults to name with its first letter lowercased. |
@Subgroup(name, prefix = "") |
name: the subgroup label. prefix: optional filter for following properties whose Godot names start with it; when omitted, it defaults to name with its first letter lowercased. |
Write prefix in the same casing as your source property names. It is converted to the snake_case Godot property name automatically; for example, movementGround matches movementGroundSpeed, which Godot receives as movement_ground_speed.
| @Script
class Player : Node() {
@Category("Player")
@Group("Movement") // Defaults to the `movement` prefix.
@Subgroup("Ground", "movementGround")
var movementGroundSpeed: Float = 5f
@Export
var movementGroundAcceleration: Float = 10f
}
|