Annotations & Exported Properties
Annotations start with @ and modify how the script or a member is treated.
15.1 What annotations are
Annotations start with @ and modify how the script or a member is treated. They replaced the 3.x keywords export, onready, tool, remote, master, puppet.
15.2 @export and its variants
@export var speed := 200.0
@export var player_name: String = "Hero"
@export var target: Node2D # node reference picked in the Inspector (4.0+)
@export var bullet_scene: PackedScene
@export var stats: CharacterStats # custom Resource
@export var waypoints: Array[Vector2] = []
@export var loot_table: Dictionary[String, int] # 4.4+
@export_range(0, 100) var volume := 50
@export_range(0.0, 1.0, 0.01) var opacity := 1.0
@export_range(0, 1000, 1, "or_greater", "suffix:px") var distance := 100
@export_range(-180, 180, 0.1, "radians_as_degrees") var angle := 0.0
@export_enum("Warrior", "Mage", "Rogue") var class_index: int
@export_enum("Slow:30", "Fast:60") var tick_rate: int = 30
@export var state: State = State.IDLE # named enum → dropdown
@export_flags("Fire", "Water", "Earth", "Air") var elements := 0
@export_flags_2d_physics var hit_layers := 1
@export_file("*.json") var config_path: String
@export_dir var levels_folder: String
@export_global_file("*.png") var external_image: String
@export_multiline var description: String
@export_placeholder("Enter name") var nickname: String
@export_color_no_alpha var tint := Color.WHITE
@export_no
…15.3 Organizing the Inspector
@export_category("Player")
@export_group("Movement")
@export var walk_speed := 200.0
@export var run_speed := 350.0
@export_subgroup("Jumping")
@export var jump_height := 64.0
@export_group("Combat", "combat_") # prefix: properties starting with combat_ go here
@export var combat_damage := 10
@export var combat_range := 32.0
@export_group("") # end the group15.4 Inspector buttons (4.4+)
@tool
extends Node2D
@export_tool_button("Randomize Color", "Callable") var randomize_btn = randomize_color
func randomize_color() -> void:
modulate = Color(randf(), randf(), randf())15.5 Other annotations
@onready var x = $Node Initialize right before _ready() (children are available)
Run the script inside the editor (Chapter 35) Custom icon for the class in the editor @abstract (4.5+) Abstract class or method
Allow the script (with static vars) to be unloaded when unused
Mark a function as remotely callable (Chapter 33) Suppress a warning for the next statement/function
@warning_ignore_start(...) / @warning_ignore_restore(...) (4.4+) Suppress warnings for a region
@icon("res://icons/coin.svg")
class_name Coin
extends Area2D
@onready var sprite: Sprite2D = $Sprite2D
@onready var anim := $AnimationPlayer as AnimationPlayer
@onready var hud: HUD = get_tree().get_first_node_in_group("hud")
@warning_ignore("unused_parameter")
func _on_body_entered(body: Node2D) -> void:
queue_free()15.6 Exporting custom resources and node arrays
@export var enemy_types: Array[EnemyData] = [] # list of resources, editable inline
@export var patrol_points: Array[Marker2D] = [] # pick nodes from the scene