Trait IScriptExtension

Source
pub trait IScriptExtension: GodotClass<Base = ScriptExtension> + You_forgot_the_attribute__godot_api {
Show 49 methods // Required methods fn editor_can_reload_from_file(&mut self) -> bool; fn can_instantiate(&self) -> bool; fn get_base_script(&self) -> Option<Gd<Script>>; fn get_global_name(&self) -> StringName; fn inherits_script(&self, script: Gd<Script>) -> bool; fn get_instance_base_type(&self) -> StringName; unsafe fn instance_create_rawptr( &self, for_object: Gd<Object>, ) -> *mut c_void; unsafe fn placeholder_instance_create_rawptr( &self, for_object: Gd<Object>, ) -> *mut c_void; fn instance_has(&self, object: Gd<Object>) -> bool; fn has_source_code(&self) -> bool; fn get_source_code(&self) -> GString; fn set_source_code(&mut self, code: GString); fn reload(&mut self, keep_state: bool) -> Error; fn get_doc_class_name(&self) -> StringName; fn get_documentation(&self) -> Array<Dictionary>; fn has_method(&self, method: StringName) -> bool; fn has_static_method(&self, method: StringName) -> bool; fn get_method_info(&self, method: StringName) -> Dictionary; fn is_tool(&self) -> bool; fn is_valid(&self) -> bool; fn get_language(&self) -> Option<Gd<ScriptLanguage>>; fn has_script_signal(&self, signal: StringName) -> bool; fn get_script_signal_list(&self) -> Array<Dictionary>; fn has_property_default_value(&self, property: StringName) -> bool; fn get_property_default_value(&self, property: StringName) -> Variant; fn update_exports(&mut self); fn get_script_method_list(&self) -> Array<Dictionary>; fn get_script_property_list(&self) -> Array<Dictionary>; fn get_member_line(&self, member: StringName) -> i32; fn get_constants(&self) -> Dictionary; fn get_members(&self) -> Array<StringName>; fn is_placeholder_fallback_enabled(&self) -> bool; fn get_rpc_config(&self) -> Variant; // Provided methods fn init(base: Base<Self::Base>) -> Self { ... } fn to_string(&self) -> GString { ... } fn on_notification(&mut self, what: ObjectNotification) { ... } fn get_property(&self, property: StringName) -> Option<Variant> { ... } fn set_property(&mut self, property: StringName, value: Variant) -> bool { ... } fn get_property_list(&mut self) -> Vec<PropertyInfo> { ... } fn validate_property(&self, property: &mut PropertyInfo) { ... } fn property_get_revert(&self, property: StringName) -> Option<Variant> { ... } unsafe fn placeholder_erased_rawptr(&mut self, placeholder: *mut c_void) { ... } fn get_class_icon_path(&self) -> GString { ... } fn get_script_method_argument_count(&self, method: StringName) -> Variant { ... } fn is_abstract(&self) -> bool { ... } fn setup_local_to_scene(&mut self) { ... } fn get_rid(&self) -> Rid { ... } fn reset_state(&mut self) { ... } fn set_path_cache(&self, path: GString) { ... }
}
Expand description

§Interface trait for class ScriptExtension.

Functions in this trait represent constructors (init) or virtual method callbacks invoked by the engine.

§Specific notes for this interface

Use this in combination with the obj::script module.

Base interfaces: IScript > IResource > IRefCounted > IObject.
(Strike-through means some intermediate Godot classes are marked final, and can thus not be inherited by GDExtension.)

See also Godot docs for ScriptExtension methods.

Required Methods§

Source

fn editor_can_reload_from_file(&mut self) -> bool

Source

fn can_instantiate(&self) -> bool

Source

fn get_base_script(&self) -> Option<Gd<Script>>

Source

fn get_global_name(&self) -> StringName

Source

fn inherits_script(&self, script: Gd<Script>) -> bool

Source

fn get_instance_base_type(&self) -> StringName

Source

unsafe fn instance_create_rawptr(&self, for_object: Gd<Object>) -> *mut c_void

§Safety

This method has automatically been marked unsafe because it accepts raw pointers as parameters. If Godot does not document any safety requirements, make sure you understand the underlying semantics.

Source

unsafe fn placeholder_instance_create_rawptr( &self, for_object: Gd<Object>, ) -> *mut c_void

§Safety

This method has automatically been marked unsafe because it accepts raw pointers as parameters. If Godot does not document any safety requirements, make sure you understand the underlying semantics.

Source

fn instance_has(&self, object: Gd<Object>) -> bool

Source

fn has_source_code(&self) -> bool

Source

fn get_source_code(&self) -> GString

Source

fn set_source_code(&mut self, code: GString)

Source

fn reload(&mut self, keep_state: bool) -> Error

Source

fn get_doc_class_name(&self) -> StringName

Source

fn get_documentation(&self) -> Array<Dictionary>

Source

fn has_method(&self, method: StringName) -> bool

Source

fn has_static_method(&self, method: StringName) -> bool

Source

fn get_method_info(&self, method: StringName) -> Dictionary

Source

fn is_tool(&self) -> bool

Source

fn is_valid(&self) -> bool

Source

fn get_language(&self) -> Option<Gd<ScriptLanguage>>

Source

fn has_script_signal(&self, signal: StringName) -> bool

Source

fn get_script_signal_list(&self) -> Array<Dictionary>

Source

fn has_property_default_value(&self, property: StringName) -> bool

Source

fn get_property_default_value(&self, property: StringName) -> Variant

Source

fn update_exports(&mut self)

Source

fn get_script_method_list(&self) -> Array<Dictionary>

Source

fn get_script_property_list(&self) -> Array<Dictionary>

Source

fn get_member_line(&self, member: StringName) -> i32

Source

fn get_constants(&self) -> Dictionary

Source

fn get_members(&self) -> Array<StringName>

Source

fn is_placeholder_fallback_enabled(&self) -> bool

Source

fn get_rpc_config(&self) -> Variant

Provided Methods§

Source

fn init(base: Base<Self::Base>) -> Self

Godot constructor, accepting an injected base object.

base refers to the base instance of the class, which can either be stored in a Base<T> field or discarded. This method returns a fully-constructed instance, which will then be moved into a Gd<T> pointer.

If the class has a #[class(init)] attribute, this method will be auto-generated and must not be overridden.

Source

fn to_string(&self) -> GString

String representation of the Godot instance.

Override this method to define how the instance is represented as a string. Used by impl Display for Gd<T>, as well as str() and print() in GDScript.

Source

fn on_notification(&mut self, what: ObjectNotification)

Called when the object receives a Godot notification.

The type of notification can be identified through what. The enum is designed to hold all possible NOTIFICATION_* constants that the current class can handle. However, this is not validated in Godot, so an enum variant Unknown exists to represent integers out of known constants (mistakes or future additions).

This method is named _notification in Godot, but on_notification in Rust. To send notifications, use the Object::notify method.

See also in Godot docs:

Source

fn get_property(&self, property: StringName) -> Option<Variant>

Called whenever get() is called or Godot gets the value of a property.

Should return the given property’s value as Some(value), or None if the property should be handled normally.

See also in Godot docs:

Source

fn set_property(&mut self, property: StringName, value: Variant) -> bool

Called whenever Godot set() is called or Godot sets the value of a property.

Should set property to the given value and return true, or return false to indicate the property should be handled normally.

See also in Godot docs:

Source

fn get_property_list(&mut self) -> Vec<PropertyInfo>

Available on since_api="4.3" only.

Called whenever Godot get_property_list() is called, the returned vector here is appended to the existing list of properties.

This should mainly be used for advanced purposes, such as dynamically updating the property list in the editor.

See also in Godot docs:

Source

fn validate_property(&self, property: &mut PropertyInfo)

Available on since_api="4.2" only.

Called whenever Godot retrieves value of property. Allows to customize existing properties. Every property info goes through this method, except properties added with get_property_list().

Exposed property here is a shared mutable reference obtained (and returned to) from Godot.

See also in the Godot docs:

Source

fn property_get_revert(&self, property: StringName) -> Option<Variant>

Called by Godot to tell if a property has a custom revert or not.

Return None for no custom revert, and return Some(value) to specify the custom revert.

This is a combination of Godot’s Object::_property_get_revert and Object::_property_can_revert. This means that this function will usually be called twice by Godot to find the revert.

Note that this should be a pure function. That is, it should always return the same value for a property as long as self remains unchanged. Otherwise, this may lead to unexpected (safe) behavior.

Source

unsafe fn placeholder_erased_rawptr(&mut self, placeholder: *mut c_void)

§Safety

This method has automatically been marked unsafe because it accepts raw pointers as parameters. If Godot does not document any safety requirements, make sure you understand the underlying semantics.

Source

fn get_class_icon_path(&self) -> GString

Source

fn get_script_method_argument_count(&self, method: StringName) -> Variant

Source

fn is_abstract(&self) -> bool

Source

fn setup_local_to_scene(&mut self)

Source

fn get_rid(&self) -> Rid

Source

fn reset_state(&mut self)

Source

fn set_path_cache(&self, path: GString)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§