脚本

Inherits: Resource < Reference < Object

继承人: CSharpScriptGDScriptNativeScriptPluginScriptVisualScript

类别: 核心

简要说明

存储为资源的类。

方法

bool

can_instance ( ) const

Script

get_base_script ( ) const

String

get_instance_base_type ( ) const

bool

has_script_signal ( String signal_name ) const

bool

has_source_code ( ) const

bool

instance_has ( Object base_object ) const

bool

is_tool ( ) const

Error

reload ( bool keep_state=false )

描述

存储为资源的类。一个脚本可以执行所有实例它的对象的功能。

这个 new 脚本子类的方法创建新实例。 Object.set_script 扩展现有对象(如果该对象的类与脚本的某个基类匹配)。

教程

属性描述

设定器

设置源代码(值)

吸气剂

获取源代码

脚本源代码或空字符串(如果源代码不可用)。设置后,不会自动重新加载类实现。

方法说明

  • bool can_instance ( ) const

返回 true 如果脚本可以实例化。

  • Script get_base_script ( ) const

返回此脚本直接继承的脚本。

  • String get_instance_base_type ( ) const

返回脚本的基类型。

  • bool has_script_signal ( String signal_name ) const

返回 true 如果脚本或基类用给定的名称定义了一个信号。

  • bool has_source_code ( ) const

返回 true 如果脚本包含非空源代码。

返回 true 如果 base_object 是此脚本的实例。

  • bool is_tool ( ) const

返回 true 如果脚本是工具脚本。可以在编辑器中运行工具脚本。

重新加载脚本的类实现。返回错误代码。