Skip to content

EditorEntity3DGizmoPlugin

Inherits: Resource < RefCounted < Object

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

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

To use EditorEntity3DGizmoPlugin, register it using the EditorPlugin.add_entity_3d_gizmo_plugin() method first.

Returns Method
void _begin_handle_action(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool) virtual
bool _can_be_hidden() virtual const
bool _can_commit_handle_on_click() virtual const
void _commit_handle(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool, restore: Variant, cancel: bool) virtual
void _commit_subgizmos(gizmo: EditorEntity3DGizmo, ids: PackedInt32Array, restores: Array[Transform3D], cancel: bool) virtual
EditorEntity3DGizmo _create_gizmo(for_node_3d: Entity3D) virtual const
String _get_gizmo_name() virtual const
String _get_handle_name(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool) virtual const
Variant _get_handle_value(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool) virtual const
int _get_priority() virtual const
Transform3D _get_subgizmo_transform(gizmo: EditorEntity3DGizmo, subgizmo_id: int) virtual const
bool _has_gizmo(for_node_3d: Entity3D) virtual const
bool _is_handle_highlighted(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool) virtual const
bool _is_selectable_when_hidden() virtual const
void _redraw(gizmo: EditorEntity3DGizmo) virtual
void _set_handle(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool, camera: Camera3D, screen_pos: Vector2) virtual
void _set_subgizmo_transform(gizmo: EditorEntity3DGizmo, subgizmo_id: int, transform: Transform3D) virtual
PackedInt32Array _subgizmos_intersect_frustum(gizmo: EditorEntity3DGizmo, camera: Camera3D, frustum_planes: Array[Plane]) virtual const
int _subgizmos_intersect_ray(gizmo: EditorEntity3DGizmo, camera: Camera3D, screen_pos: Vector2) virtual const
void add_material(name: String, material: StandardMaterial3D)
void create_handle_material(name: String, billboard: bool = false, texture: Texture2D = null)
void create_icon_material(name: String, texture: Texture2D, on_top: bool = false, color: Color = Color(1, 1, 1, 1))
void create_material(name: String, color: Color, billboard: bool = false, on_top: bool = false, use_vertex_color: bool = false)
StandardMaterial3D get_material(name: String, gizmo: EditorEntity3DGizmo = null)

_begin_handle_action

void _begin_handle_action(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool) virtual

_can_be_hidden

bool _can_be_hidden() virtual const

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

_can_commit_handle_on_click

bool _can_commit_handle_on_click() virtual const

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.

_commit_handle

void _commit_handle(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool, restore: Variant, cancel: bool) virtual

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

Called for this plugin’s active gizmos.

_commit_subgizmos

void _commit_subgizmos(gizmo: EditorEntity3DGizmo, ids: PackedInt32Array, restores: Array[Transform3D], cancel: bool) virtual

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 Entity3D. Called for this plugin’s active gizmos.

_create_gizmo

EditorEntity3DGizmo _create_gizmo(for_node_3d: Entity3D) virtual const

Override this method to return a custom EditorEntity3DGizmo for the 3D nodes of your choice, return null for the rest of nodes. See also _has_gizmo().

_get_gizmo_name

String _get_gizmo_name() virtual const

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

_get_handle_name

String _get_handle_name(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool) virtual const

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

_get_handle_value

Variant _get_handle_value(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool) virtual const

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 EditorEntity3DGizmo.add_handles() for more information).

Called for this plugin’s active gizmos.

_get_priority

int _get_priority() virtual const

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.

_get_subgizmo_transform

Transform3D _get_subgizmo_transform(gizmo: EditorEntity3DGizmo, subgizmo_id: int) virtual const

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 Entity3D. 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.

_has_gizmo

bool _has_gizmo(for_node_3d: Entity3D) virtual const

Override this method to define which Entity3D nodes have a gizmo from this plugin. Whenever a Entity3D node is added to a scene this method is called, if it returns true the node gets a generic EditorEntity3DGizmo assigned and is added to this plugin’s list of active gizmos.

_is_handle_highlighted

bool _is_handle_highlighted(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool) virtual const

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 EditorEntity3DGizmo.add_handles() for more information). Called for this plugin’s active gizmos.

_is_selectable_when_hidden

bool _is_selectable_when_hidden() virtual const

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

_redraw

void _redraw(gizmo: EditorEntity3DGizmo) virtual

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

_set_handle

void _set_handle(gizmo: EditorEntity3DGizmo, handle_id: int, secondary: bool, camera: Camera3D, screen_pos: Vector2) virtual

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

Called for this plugin’s active gizmos.

_set_subgizmo_transform

void _set_subgizmo_transform(gizmo: EditorEntity3DGizmo, subgizmo_id: int, transform: Transform3D) virtual

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 Entity3D’s local coordinate system. Called for this plugin’s active gizmos.

_subgizmos_intersect_frustum

PackedInt32Array _subgizmos_intersect_frustum(gizmo: EditorEntity3DGizmo, camera: Camera3D, frustum_planes: Array[Plane]) virtual const

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.

_subgizmos_intersect_ray

int _subgizmos_intersect_ray(gizmo: EditorEntity3DGizmo, camera: Camera3D, screen_pos: Vector2) virtual const

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.

add_material

void add_material(name: String, material: StandardMaterial3D)

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

create_handle_material

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

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 EditorEntity3DGizmo.add_handles(). Should not be overridden.

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

create_icon_material

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

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 EditorEntity3DGizmo.add_unscaled_billboard(). Should not be overridden.

create_material

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

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 EditorEntity3DGizmo.add_mesh() and EditorEntity3DGizmo.add_lines(). Should not be overridden.

get_material

StandardMaterial3D get_material(name: String, gizmo: EditorEntity3DGizmo = null)

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