Class EditorNode3DGizmoPlugin
A class used by the editor to define Node3D gizmo types.
- Inheritance
-
EditorNode3DGizmoPlugin
Remarks
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.
See Also
Methods
_begin_handle_action(EditorNode3DGizmo, int, bool)
Qualifiers: virtual
void _begin_handle_action(EditorNode3DGizmo gizmo, int handle_id, bool secondary)
Parameters
gizmoEditorNode3DGizmohandle_idintsecondarybool
_can_be_hidden
Qualifiers: virtualconst
Override this method to define whether the gizmos handled by this plugin can be hidden or not. Returns true if not overridden.
bool _can_be_hidden
_commit_handle(EditorNode3DGizmo, int, bool, Variant, bool)
Qualifiers: virtual
Override this method to commit a handle being edited (handles must have been previously added by EditorNode3DGizmo.add_handles during EditorNode3DGizmoPlugin._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.
void _commit_handle(EditorNode3DGizmo gizmo, int handle_id, bool secondary, Variant restore, bool cancel)
Parameters
gizmoEditorNode3DGizmohandle_idintsecondaryboolrestoreVariantcancelbool
_commit_subgizmos(EditorNode3DGizmo, PackedInt32Array, Transform3D[], bool)
Qualifiers: virtual
Override this method to commit a group of subgizmos being edited (see EditorNode3DGizmoPlugin._subgizmos_intersect_ray and EditorNode3DGizmoPlugin._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.
void _commit_subgizmos(EditorNode3DGizmo gizmo, PackedInt32Array ids, Transform3D[] restores, bool cancel)
Parameters
gizmoEditorNode3DGizmoidsPackedInt32ArrayrestoresTransform3D[]cancelbool
_create_gizmo(Node3D)
Qualifiers: virtualconst
Override this method to return a custom EditorNode3DGizmo for the 3D nodes of your choice, return null for the rest of nodes. See also EditorNode3DGizmoPlugin._has_gizmo.
EditorNode3DGizmo _create_gizmo(Node3D for_node_3d)
Parameters
for_node_3dNode3D
_get_gizmo_name
Qualifiers: virtualconst
Override this method to provide the name that will appear in the gizmo visibility menu.
String _get_gizmo_name
_get_handle_name(EditorNode3DGizmo, int, bool)
Qualifiers: virtualconst
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.
String _get_handle_name(EditorNode3DGizmo gizmo, int handle_id, bool secondary)
Parameters
gizmoEditorNode3DGizmohandle_idintsecondarybool
_get_handle_value(EditorNode3DGizmo, int, bool)
Qualifiers: virtualconst
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 EditorNode3DGizmoPlugin._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.
Variant _get_handle_value(EditorNode3DGizmo gizmo, int handle_id, bool secondary)
Parameters
gizmoEditorNode3DGizmohandle_idintsecondarybool
_get_priority
Qualifiers: virtualconst
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.
int _get_priority
_get_subgizmo_transform(EditorNode3DGizmo, int)
Qualifiers: virtualconst
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 EditorNode3DGizmoPlugin._commit_subgizmos. Called for this plugin's active gizmos.
Transform3D _get_subgizmo_transform(EditorNode3DGizmo gizmo, int subgizmo_id)
Parameters
gizmoEditorNode3DGizmosubgizmo_idint
_has_gizmo(Node3D)
Qualifiers: virtualconst
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.
bool _has_gizmo(Node3D for_node_3d)
Parameters
for_node_3dNode3D
_is_handle_highlighted(EditorNode3DGizmo, int, bool)
Qualifiers: virtualconst
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.
bool _is_handle_highlighted(EditorNode3DGizmo gizmo, int handle_id, bool secondary)
Parameters
gizmoEditorNode3DGizmohandle_idintsecondarybool
_is_selectable_when_hidden
Qualifiers: virtualconst
Override this method to define whether Node3D with this gizmo should be selectable even when the gizmo is hidden.
bool _is_selectable_when_hidden
_redraw(EditorNode3DGizmo)
Qualifiers: virtual
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.
void _redraw(EditorNode3DGizmo gizmo)
Parameters
gizmoEditorNode3DGizmo
_set_handle(EditorNode3DGizmo, int, bool, Camera3D, Vector2)
Qualifiers: virtual
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.
void _set_handle(EditorNode3DGizmo gizmo, int handle_id, bool secondary, Camera3D camera, Vector2 screen_pos)
Parameters
gizmoEditorNode3DGizmohandle_idintsecondaryboolcameraCamera3Dscreen_posVector2
_set_subgizmo_transform(EditorNode3DGizmo, int, Transform3D)
Qualifiers: virtual
Override this method to update the node properties during subgizmo editing (see EditorNode3DGizmoPlugin._subgizmos_intersect_ray and EditorNode3DGizmoPlugin._subgizmos_intersect_frustum). The transform is given in the Node3D's local coordinate system. Called for this plugin's active gizmos.
void _set_subgizmo_transform(EditorNode3DGizmo gizmo, int subgizmo_id, Transform3D transform)
Parameters
gizmoEditorNode3DGizmosubgizmo_idinttransformTransform3D
_subgizmos_intersect_frustum(EditorNode3DGizmo, Camera3D, Plane[])
Qualifiers: virtualconst
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 EditorNode3DGizmoPlugin._get_subgizmo_transform or EditorNode3DGizmoPlugin._commit_subgizmos. Called for this plugin's active gizmos.
PackedInt32Array _subgizmos_intersect_frustum(EditorNode3DGizmo gizmo, Camera3D camera, Plane[] frustum_planes)
Parameters
gizmoEditorNode3DGizmocameraCamera3Dfrustum_planesPlane[]
_subgizmos_intersect_ray(EditorNode3DGizmo, Camera3D, Vector2)
Qualifiers: virtualconst
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 EditorNode3DGizmoPlugin._get_subgizmo_transform or EditorNode3DGizmoPlugin._commit_subgizmos. Called for this plugin's active gizmos.
int _subgizmos_intersect_ray(EditorNode3DGizmo gizmo, Camera3D camera, Vector2 screen_pos)
Parameters
gizmoEditorNode3DGizmocameraCamera3Dscreen_posVector2
add_material(String, StandardMaterial3D)
Adds a new material to the internal material list for the plugin. It can then be accessed with EditorNode3DGizmoPlugin.get_material. Should not be overridden.
void add_material(String name, StandardMaterial3D material)
Parameters
nameStringmaterialStandardMaterial3D
create_handle_material(String, bool, Texture2D)
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 EditorNode3DGizmoPlugin.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.
void create_handle_material(String name, bool billboard, Texture2D texture)
Parameters
create_icon_material(String, Texture2D, bool, Color)
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 EditorNode3DGizmoPlugin.get_material and used in EditorNode3DGizmo.add_unscaled_billboard. Should not be overridden.
void create_icon_material(String name, Texture2D texture, bool on_top, Color color)
Parameters
create_material(String, Color, bool, bool, bool)
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 EditorNode3DGizmoPlugin.get_material and used in EditorNode3DGizmo.add_mesh and EditorNode3DGizmo.add_lines. Should not be overridden.
void create_material(String name, Color color, bool billboard, bool on_top, bool use_vertex_color)
Parameters
get_material(String, EditorNode3DGizmo)
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).
StandardMaterial3D get_material(String name, EditorNode3DGizmo gizmo)
Parameters
nameStringgizmoEditorNode3DGizmo