Trait IEditorNode3DGizmoPlugin
pub trait IEditorNode3DGizmoPlugin: GodotClass<Base = EditorNode3DGizmoPlugin> + You_forgot_the_attribute__godot_api {
Show 30 methods
// Provided methods
fn init(base: Base<Self::Base>) -> Self { ... }
fn on_notification(&mut self, what: ObjectNotification) { ... }
fn on_get(&self, property: StringName) -> Option<Variant> { ... }
fn on_set(&mut self, property: StringName, value: Variant) -> bool { ... }
fn on_validate_property(&self, property: &mut PropertyInfo) { ... }
fn on_get_property_list(&mut self) -> Vec<PropertyInfo> { ... }
fn on_property_get_revert(&self, property: StringName) -> Option<Variant> { ... }
fn to_string(&self) -> GString { ... }
fn has_gizmo(&self, for_node_3d: Option<Gd<Node3D>>) -> bool { ... }
fn create_gizmo(
&self,
for_node_3d: Option<Gd<Node3D>>,
) -> Option<Gd<EditorNode3DGizmo>> { ... }
fn get_gizmo_name(&self) -> GString { ... }
fn get_priority(&self) -> i32 { ... }
fn can_be_hidden(&self) -> bool { ... }
fn is_selectable_when_hidden(&self) -> bool { ... }
fn redraw(&mut self, gizmo: Option<Gd<EditorNode3DGizmo>>) { ... }
fn get_handle_name(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
) -> GString { ... }
fn is_handle_highlighted(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
) -> bool { ... }
fn get_handle_value(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
) -> Variant { ... }
fn begin_handle_action(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
) { ... }
fn set_handle(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
camera: Option<Gd<Camera3D>>,
screen_pos: Vector2,
) { ... }
fn commit_handle(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
restore: Variant,
cancel: bool,
) { ... }
fn subgizmos_intersect_ray(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
camera: Option<Gd<Camera3D>>,
screen_pos: Vector2,
) -> i32 { ... }
fn subgizmos_intersect_frustum(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
camera: Option<Gd<Camera3D>>,
frustum_planes: Array<Plane>,
) -> PackedArray<i32> { ... }
fn get_subgizmo_transform(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
subgizmo_id: i32,
) -> Transform3D { ... }
fn set_subgizmo_transform(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
subgizmo_id: i32,
transform: Transform3D,
) { ... }
fn commit_subgizmos(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
ids: PackedArray<i32>,
restores: Array<Transform3D>,
cancel: 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 EditorNode3DGizmoPlugin.
Functions in this trait represent constructors (init) or virtual method callbacks invoked by the engine.
§Related symbols
Base interfaces: IResource > IRefCounted > IObject.
Provided Methods§
fn init(base: Base<Self::Base>) -> Self
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.
fn on_notification(&mut self, what: ObjectNotification)
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:
fn on_get(&self, property: StringName) -> Option<Variant>
fn on_get(&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:
fn on_set(&mut self, property: StringName, value: Variant) -> bool
fn on_set(&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:
fn on_validate_property(&self, property: &mut PropertyInfo)
fn on_validate_property(&self, property: &mut PropertyInfo)
Called whenever Godot retrieves value of property. Allows to customize existing properties.
Every property info goes through this method, except properties added with on_get_property_list().
Exposed property here is a shared mutable reference obtained (and returned to) from Godot.
See also in the Godot docs:
fn on_get_property_list(&mut self) -> Vec<PropertyInfo>
Available on since_api=4.3 only.
fn on_get_property_list(&mut self) -> Vec<PropertyInfo>
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:
fn on_property_get_revert(&self, property: StringName) -> Option<Variant>
fn on_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.
fn to_string(&self) -> GString
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.
fn has_gizmo(&self, for_node_3d: Option<Gd<Node3D>>) -> bool
fn has_gizmo(&self, for_node_3d: Option<Gd<Node3D>>) -> bool
Override this method to define which Node3D nodes have a gizmo from this plugin. Whenever a Node3D node is added to a scene this method is called, if it returns true the node gets a generic EditorNode3DGizmo assigned and is added to this plugin’s list of active gizmos.
fn create_gizmo(
&self,
for_node_3d: Option<Gd<Node3D>>,
) -> Option<Gd<EditorNode3DGizmo>>
fn create_gizmo( &self, for_node_3d: Option<Gd<Node3D>>, ) -> Option<Gd<EditorNode3DGizmo>>
Override this method to return a custom EditorNode3DGizmo for the 3D nodes of your choice, return null for the rest of nodes. See also has_gizmo.
fn get_gizmo_name(&self) -> GString
fn get_gizmo_name(&self) -> GString
Override this method to provide the name that will appear in the gizmo visibility menu.
fn get_priority(&self) -> i32
fn get_priority(&self) -> i32
Override this method to set the gizmo’s priority. Gizmos with higher priority will have precedence when processing inputs like handles or subgizmos selection.
All built-in editor gizmos return a priority of -1. If not overridden, this method will return 0, which means custom gizmos will automatically get higher priority than built-in gizmos.
Override this method to define whether the gizmos handled by this plugin can be hidden or not. Returns true if not overridden.
Override this method to define whether Node3D with this gizmo should be selectable even when the gizmo is hidden.
fn redraw(&mut self, gizmo: Option<Gd<EditorNode3DGizmo>>)
fn redraw(&mut self, gizmo: Option<Gd<EditorNode3DGizmo>>)
Override this method to add all the gizmo elements whenever a gizmo update is requested. It’s common to call clear at the beginning of this method and then add visual elements depending on the node’s properties.
fn get_handle_name(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
) -> GString
fn get_handle_name( &self, gizmo: Option<Gd<EditorNode3DGizmo>>, handle_id: i32, secondary: bool, ) -> GString
Override this method to provide gizmo’s handle names. The secondary argument is true when the requested handle is secondary (see add_handles for more information). Called for this plugin’s active gizmos.
fn is_handle_highlighted(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
) -> bool
fn is_handle_highlighted( &self, gizmo: Option<Gd<EditorNode3DGizmo>>, handle_id: i32, secondary: bool, ) -> bool
Override this method to return true whenever to given handle should be highlighted in the editor. The secondary argument is true when the requested handle is secondary (see add_handles for more information). Called for this plugin’s active gizmos.
fn get_handle_value(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
) -> Variant
fn get_handle_value( &self, gizmo: Option<Gd<EditorNode3DGizmo>>, handle_id: i32, secondary: bool, ) -> Variant
Override this method to return the current value of a handle. This value will be requested at the start of an edit and used as the restore argument in commit_handle.
The secondary argument is true when the requested handle is secondary (see add_handles for more information).
Called for this plugin’s active gizmos.
fn begin_handle_action( &mut self, gizmo: Option<Gd<EditorNode3DGizmo>>, handle_id: i32, secondary: bool, )
fn set_handle(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
camera: Option<Gd<Camera3D>>,
screen_pos: Vector2,
)
fn set_handle( &mut self, gizmo: Option<Gd<EditorNode3DGizmo>>, handle_id: i32, secondary: bool, camera: Option<Gd<Camera3D>>, screen_pos: Vector2, )
Override this method to update the node’s properties when the user drags a gizmo handle (previously added with add_handles). The provided screen_pos is the mouse position in screen coordinates and the camera can be used to convert it to raycasts.
The secondary argument is true when the edited handle is secondary (see add_handles for more information).
Called for this plugin’s active gizmos.
fn commit_handle(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
handle_id: i32,
secondary: bool,
restore: Variant,
cancel: bool,
)
fn commit_handle( &mut self, gizmo: Option<Gd<EditorNode3DGizmo>>, handle_id: i32, secondary: bool, restore: Variant, cancel: bool, )
Override this method to commit a handle being edited (handles must have been previously added by add_handles during redraw). This usually means creating an UndoRedo action for the change, using the current handle value as “do” and the restore argument as “undo”.
If the cancel argument is true, the restore value should be directly set, without any UndoRedo action.
The secondary argument is true when the committed handle is secondary (see add_handles for more information).
Called for this plugin’s active gizmos.
fn subgizmos_intersect_ray(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
camera: Option<Gd<Camera3D>>,
screen_pos: Vector2,
) -> i32
fn subgizmos_intersect_ray( &self, gizmo: Option<Gd<EditorNode3DGizmo>>, camera: Option<Gd<Camera3D>>, screen_pos: Vector2, ) -> i32
Override this method to allow selecting subgizmos using mouse clicks. Given a camera and a screen_pos in screen coordinates, this method should return which subgizmo should be selected. The returned value should be a unique subgizmo identifier, which can have any non-negative value and will be used in other virtual methods like get_subgizmo_transform or commit_subgizmos. Called for this plugin’s active gizmos.
fn subgizmos_intersect_frustum(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
camera: Option<Gd<Camera3D>>,
frustum_planes: Array<Plane>,
) -> PackedArray<i32>
fn subgizmos_intersect_frustum( &self, gizmo: Option<Gd<EditorNode3DGizmo>>, camera: Option<Gd<Camera3D>>, frustum_planes: Array<Plane>, ) -> PackedArray<i32>
Override this method to allow selecting subgizmos using mouse drag box selection. Given a camera and frustum_planes, this method should return which subgizmos are contained within the frustums. The frustum_planes argument consists of an array with all the Planes that make up the selection frustum. The returned value should contain a list of unique subgizmo identifiers, these identifiers can have any non-negative value and will be used in other virtual methods like get_subgizmo_transform or commit_subgizmos. Called for this plugin’s active gizmos.
fn get_subgizmo_transform(
&self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
subgizmo_id: i32,
) -> Transform3D
fn get_subgizmo_transform( &self, gizmo: Option<Gd<EditorNode3DGizmo>>, subgizmo_id: i32, ) -> Transform3D
Override this method to return the current transform of a subgizmo. As with all subgizmo methods, the transform should be in local space respect to the gizmo’s Node3D. This transform will be requested at the start of an edit and used in the restore argument in commit_subgizmos. Called for this plugin’s active gizmos.
fn set_subgizmo_transform(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
subgizmo_id: i32,
transform: Transform3D,
)
fn set_subgizmo_transform( &mut self, gizmo: Option<Gd<EditorNode3DGizmo>>, subgizmo_id: i32, transform: Transform3D, )
Override this method to update the node properties during subgizmo editing (see subgizmos_intersect_ray and subgizmos_intersect_frustum). The transform is given in the Node3D’s local coordinate system. Called for this plugin’s active gizmos.
fn commit_subgizmos(
&mut self,
gizmo: Option<Gd<EditorNode3DGizmo>>,
ids: PackedArray<i32>,
restores: Array<Transform3D>,
cancel: bool,
)
fn commit_subgizmos( &mut self, gizmo: Option<Gd<EditorNode3DGizmo>>, ids: PackedArray<i32>, restores: Array<Transform3D>, cancel: bool, )
Override this method to commit a group of subgizmos being edited (see subgizmos_intersect_ray and subgizmos_intersect_frustum). This usually means creating an UndoRedo action for the change, using the current transforms as “do” and the restores transforms as “undo”.
If the cancel argument is true, the restores transforms should be directly set, without any UndoRedo action. As with all subgizmo methods, transforms are given in local space respect to the gizmo’s Node3D. Called for this plugin’s active gizmos.
fn setup_local_to_scene(&mut self)
fn setup_local_to_scene(&mut self)
Override this method to customize the newly duplicated resource created from instantiate, if the original’s [member resource_local_to_scene] is set to true.
Example: Set a random damage value to every local resource from an instantiated scene:
extends Resource
var damage = 0
func _setup_local_to_scene():
damage = randi_range(10, 40)fn reset_state(&mut self)
fn reset_state(&mut self)
For resources that store state in non-exported properties, such as via on_validate_property or on_get_property_list, this method must be implemented to clear them.
fn set_path_cache(&self, path: GString)
fn set_path_cache(&self, path: GString)
Override this method to execute additional logic after set_path_cache is called on this object.
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.