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...
ClassDB
繼承: Object
類資訊的儲存庫。
說明
Provides access to metadata stored for every available engine class.
Note: Script-defined classes with class_name are not part of ClassDB, so they will not return reflection data such as a method or property list. However, GDExtension-defined classes are part of ClassDB, so they will return reflection data.
方法
列舉
enum APIType: 🔗
APIType API_CORE = 0
Native Core class type.
APIType API_EDITOR = 1
Native Editor class type.
APIType API_EXTENSION = 2
GDExtension class type.
APIType API_EDITOR_EXTENSION = 3
GDExtension Editor class type.
APIType API_NONE = 4
Unknown class type.
方法說明
bool can_instantiate(class: StringName) const 🔗
如果可以從指定的 class 產生實體物件,則返回 true,否則返回 false。
Variant class_call_static(class: StringName, method: StringName, ...) vararg 🔗
Calls a static method on a class.
bool class_exists(class: StringName) const 🔗
返回指定的類 class 是否可用。
APIType class_get_api_type(class: StringName) const 🔗
Returns the API type of the specified class.
PackedStringArray class_get_enum_constants(class: StringName, enum: StringName, no_inheritance: bool = false) const 🔗
返回一個陣列,其中包含 class 或其祖先的 enum 中的所有鍵。
PackedStringArray class_get_enum_list(class: StringName, no_inheritance: bool = false) const 🔗
返回一個陣列,其中包含 class 或其祖先的所有列舉。
int class_get_integer_constant(class: StringName, name: StringName) const 🔗
返回 class 或其父級的整數常數值 name。如果找不到該常數,則總是返回0。
StringName class_get_integer_constant_enum(class: StringName, name: StringName, no_inheritance: bool = false) const 🔗
返回 class 或其祖先的整數常數 name 所屬的列舉。
PackedStringArray class_get_integer_constant_list(class: StringName, no_inheritance: bool = false) const 🔗
返回包含 class 或其父級全部整數常數的名稱陣列。
int class_get_method_argument_count(class: StringName, method: StringName, no_inheritance: bool = false) const 🔗
Returns the number of arguments of the method method of class or its ancestry if no_inheritance is false.
Array[Dictionary] class_get_method_list(class: StringName, no_inheritance: bool = false) const 🔗
如果 no_inheritance 為 false,則返回包含 class 或其祖先的所有方法的陣列。陣列的每個元素都是一個 Dictionary,包含以下鍵:args、default_args、flags、id、name、return: (class_name, hint, hint_string, name, type, usage)。
注意:在匯出的發行版本中,除錯資訊不可用,因此返回的字典將僅包含方法名稱。
Variant class_get_property(object: Object, property: StringName) const 🔗
返回 object 或其父級 property 的屬性值。
Variant class_get_property_default_value(class: StringName, property: StringName) const 🔗
Returns the default value of property of class or its ancestor classes.
StringName class_get_property_getter(class: StringName, property: StringName) 🔗
Returns the getter method name of property of class.
Array[Dictionary] class_get_property_list(class: StringName, no_inheritance: bool = false) const 🔗
如果 no_inheritance 為 false,則返回包含 class 或其祖先的所有屬性的陣列。
StringName class_get_property_setter(class: StringName, property: StringName) 🔗
Returns the setter method name of property of class.
Dictionary class_get_signal(class: StringName, signal: StringName) const 🔗
返回 class 或其祖先的 signal 資料。返回值是具有以下鍵的 Dictionary:args、default_args、flags、id、name、return: (class_name, hint, hint_string, name, type, usage)。
Array[Dictionary] class_get_signal_list(class: StringName, no_inheritance: bool = false) const 🔗
如果 no_inheritance 為 false,則返回包含 class 或其祖先的所有訊號的陣列。陣列的每個元素都是一個如 class_get_signal() 中所述的 Dictionary。
bool class_has_enum(class: StringName, name: StringName, no_inheritance: bool = false) const 🔗
返回類 class 或其祖類是否有名為 name 的列舉。
bool class_has_integer_constant(class: StringName, name: StringName) const 🔗
返回類 class 或其祖類是否有名為 name 的整數常數。
bool class_has_method(class: StringName, method: StringName, no_inheritance: bool = false) const 🔗
返回類 class 是否有名為 method 的方法(如果 no_inheritance 為 false 則還會檢查其祖類)。
bool class_has_signal(class: StringName, signal: StringName) const 🔗
返回類 class 或其祖類是否有名為 signal 的訊號。
Error class_set_property(object: Object, property: StringName, value: Variant) const 🔗
將物件 object 的 property 屬性值設定為 value。
PackedStringArray get_class_list() const 🔗
Returns the names of all engine classes available.
Note: Script-defined classes with class_name are not included in this list. Use ProjectSettings.get_global_class_list() to get a list of script-defined classes instead.
PackedStringArray get_inheriters_from_class(class: StringName) const 🔗
Returns the names of all engine classes that directly or indirectly inherit from class.
StringName get_parent_class(class: StringName) const 🔗
返回 class 的父類。
Variant instantiate(class: StringName) const 🔗
建立 class 的實例。
bool is_class_enabled(class: StringName) const 🔗
返回這個 class 是否已啟用。
bool is_class_enum_bitfield(class: StringName, enum: StringName, no_inheritance: bool = false) const 🔗
Returns whether class (or its ancestor classes if no_inheritance is false) has an enum called enum that is a bitfield.
bool is_parent_class(class: StringName, inherits: StringName) const 🔗
返回 inherits 是否為 class 的祖先。