Index · Object → RefCounted → Resource → EditorNode3DGizmoPlugin

EditorNode3DGizmoPlugin

A class used by the editor to define Node3D gizmo types.

Class Description

EditorNode3DGizmoPlugin allows you to define a new type of Gizmo. There are two main ways to do so: extending EditorNode3DGizmoPlugin for the simpler gizmos, or creating a new EditorNode3DGizmo type. See the tutorial in the documentation for more info.

To use EditorNode3DGizmoPlugin, register it using the EditorPlugin.add_node_3d_gizmo_plugin() method first.

Properties

Inherited from Resource (4)

Methods

func _begin_handle_action(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) -> void
func _can_be_hidden() -> bool

Override this method to define whether the gizmos handled by this plugin can be hidden or not. Returns true if not overridden.

func _can_commit_handle_on_click() -> bool

Override this method to define whether the gizmos should commit when the final handle position is the same as the initial one. Returns false if not overridden.

func _commit_handle(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool, restore: Variant, cancel: bool) -> void

Override this method to commit a handle being edited (handles must have been previously added by EditorNode3DGizmo.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 EditorNode3DGizmo.add_handles() for more information).

Called for this plugin's active gizmos.

func _commit_subgizmos(gizmo: EditorNode3DGizmo, ids: PackedInt32Array, restores: Transform3D[], cancel: bool) -> void

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.

func _create_gizmo(for_node_3d: Node3D) -> 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().

func _get_gizmo_name() -> String

Override this method to provide the name that will appear in the gizmo visibility menu.

func _get_handle_name(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) -> String

Override this method to provide gizmo's handle names. The secondary argument is true when the requested handle is secondary (see EditorNode3DGizmo.add_handles() for more information). Called for this plugin's active gizmos.

func _get_handle_value(gizmo: EditorNode3DGizmo, handle_id: int, 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 EditorNode3DGizmo.add_handles() for more information).

Called for this plugin's active gizmos.

func _get_priority() -> int

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.

func _get_subgizmo_transform(gizmo: EditorNode3DGizmo, subgizmo_id: int) -> 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.

func _has_gizmo(for_node_3d: 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.

func _is_handle_highlighted(gizmo: EditorNode3DGizmo, handle_id: int, 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 EditorNode3DGizmo.add_handles() for more information). Called for this plugin's active gizmos.

func _is_selectable_when_hidden() -> bool

Override this method to define whether Node3D with this gizmo should be selectable even when the gizmo is hidden.

func _redraw(gizmo: EditorNode3DGizmo) -> void

Override this method to add all the gizmo elements whenever a gizmo update is requested. It's common to call EditorNode3DGizmo.clear() at the beginning of this method and then add visual elements depending on the node's properties.

func _set_handle(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool, camera: Camera3D, screen_pos: Vector2) -> void

Override this method to update the node's properties when the user drags a gizmo handle (previously added with EditorNode3DGizmo.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 EditorNode3DGizmo.add_handles() for more information).

Called for this plugin's active gizmos.

func _set_subgizmo_transform(gizmo: EditorNode3DGizmo, subgizmo_id: int, transform: Transform3D) -> void

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.

func _subgizmos_intersect_frustum(gizmo: EditorNode3DGizmo, camera: Camera3D, frustum_planes: Plane[]) -> PackedInt32Array

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.

func _subgizmos_intersect_ray(gizmo: EditorNode3DGizmo, camera: Camera3D, screen_pos: Vector2) -> int

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.

func add_material(name: String, material: StandardMaterial3D) -> void

Adds a new material to the internal material list for the plugin. It can then be accessed with get_material(). Should not be overridden.

func create_handle_material(name: String, billboard: bool = false, texture: Texture2D = null) -> void

Creates a handle material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with get_material() and used in EditorNode3DGizmo.add_handles(). Should not be overridden.

You can optionally provide a texture to use instead of the default icon.

func create_icon_material(name: String, texture: Texture2D, on_top: bool = false, color: Color = Color(1, 1, 1, 1)) -> void

Creates an icon material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with get_material() and used in EditorNode3DGizmo.add_unscaled_billboard(). Should not be overridden.

func create_material(name: String, color: Color, billboard: bool = false, on_top: bool = false, use_vertex_color: bool = false) -> void

Creates an unshaded material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with get_material() and used in EditorNode3DGizmo.add_mesh() and EditorNode3DGizmo.add_lines(). Should not be overridden.

func get_material(name: String, gizmo: EditorNode3DGizmo = null) -> StandardMaterial3D

Gets material from the internal list of materials. If an EditorNode3DGizmo is provided, it will try to get the corresponding variant (selected and/or editable).

Inherited from Resource (18)
func _get_rid() -> RID
func _reset_state() -> void
func _set_path_cache(path: String) -> void
func _setup_local_to_scene() -> void
func copy_from_resource(resource: Resource) -> Error
func duplicate(deep: bool = false) -> Resource
func duplicate_deep(deep_subresources_mode: Resource.DeepDuplicateMode = 1) -> Resource
func emit_changed() -> void
func get_rid() -> RID
func is_built_in() -> bool
func reset_state() -> void
func set_id_for_path(path: String, id: String) -> void
func set_path_cache(path: String) -> void
func setup_local_to_scene() -> void
func take_over_path(path: String) -> void
Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Resource (2)
signal changed()
Inherited from Object (2)