腳本開發

GDScript

註解方針

為作用於腳本或其程式碼的修飾符建立註解。此外,針對 Godot 引擎與編輯器專屬的行為,也應建立註解;如果主要目的是影響引擎或編輯器處理或互動腳本的方式,則應將該標記實作為註解。

不要為一般程式語言特性建立註解。

# Affects how the editor treats this script.
@icon("res://path/to/class/icon.svg")

# Affects how the engine interacts with this script.
@onready var character_name = $Label

# static is a general programming language feature.
static var num_players = 2

由於歷史原因,部分現有的註解與關鍵字並未嚴格遵循這些方針。針對某功能應實作為註解還是語言關鍵字,這需要與其他 GDScript 開發者討論後,再做出細緻的決定。