Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

GDScript

繼承: Script < Resource < RefCounted < Object

用 GDScript 程式設計語言實作的腳本。

說明

用 GDScript 程式設計語言實作的腳本,使用 .gd 副檔名保存。該腳本擴充了將其產生實體的所有物件的功能。

呼叫 new() 會建立該腳本的全新實例。如果現有物件的類與該腳本的基底類別相匹配,那麼 Object.set_script() 就能夠擴充該物件。

如果你想要查看 GDScript 的內建函式,請移步 @GDScript

教學

方法

Variant

new(...) vararg


方法說明

Variant new(...) vararg 🔗

回傳此腳本的一個新實例。

var MyClass = load("myclass.gd")
var instance = MyClass.new()
print(instance.get_script() == MyClass) # 輸出 true