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.
Checking the stable version of the documentation...
GDScript
继承: Script < Resource < RefCounted < Object
用 GDScript 编程语言实现的脚本。
描述
用 GDScript 编程语言实现的脚本,使用 .gd
扩展名保存。该脚本扩展了将其实例化的所有对象的功能。
调用 new() 会创建该脚本的全新实例。如果现有对象的类与该脚本的基类相匹配,那么 Object.set_script() 就能够扩展该对象。
如果你想要查看 GDScript 的内置函数,请移步 @GDScript。
教程
方法
new(...) vararg |
方法说明
返回该脚本的一个新实例化对象。
var MyClass = load("myclass.gd")
var instance = MyClass.new()
assert(instance.get_script() == MyClass) # 输出 true