Table of Contents

Class EditorNode3DGizmo

Namespace
Godot
Assembly
GodotSharpEditor.dll

Gizmo that is used for providing custom visualization and editing (handles and subgizmos) for Node3D objects. Can be overridden to create custom gizmos, but for simple gizmos creating a EditorNode3DGizmoPlugin is usually recommended.

public class EditorNode3DGizmo : Node3DGizmo, IDisposable
Inheritance
EditorNode3DGizmo
Implements
Inherited Members

Constructors

EditorNode3DGizmo()

public EditorNode3DGizmo()

Methods

AddCollisionSegments(Vector3[])

Adds the specified segments to the gizmo's collision shape for picking. Call this method during _Redraw().

public void AddCollisionSegments(Vector3[] segments)

Parameters

segments Vector3[]

AddCollisionTriangles(TriangleMesh)

Adds collision triangles to the gizmo for picking. A TriangleMesh can be generated from a regular Mesh too. Call this method during _Redraw().

public void AddCollisionTriangles(TriangleMesh triangles)

Parameters

triangles TriangleMesh

AddHandles(Vector3[], Material, int[], bool, bool)

Adds a list of handles (points) which can be used to edit the properties of the gizmo's Node3D. The ids argument can be used to specify a custom identifier for each handle, if an empty array is passed, the ids will be assigned automatically from the handles argument order.

The secondary argument marks the added handles as secondary, meaning they will normally have lower selection priority than regular handles. When the user is holding the shift key secondary handles will switch to have higher priority than regular handles. This change in priority can be used to place multiple handles at the same point while still giving the user control on their selection.

There are virtual methods which will be called upon editing of these handles. Call this method during _Redraw().

public void AddHandles(Vector3[] handles, Material material, int[] ids, bool billboard = false, bool secondary = false)

Parameters

handles Vector3[]
material Material
ids int[]
billboard bool
secondary bool

AddLines(Vector3[], Material, bool, Color?)

Adds lines to the gizmo (as sets of 2 points), with a given material. The lines are used for visualizing the gizmo. Call this method during _Redraw().

public void AddLines(Vector3[] lines, Material material, bool billboard = false, Color? modulate = null)

Parameters

lines Vector3[]
material Material
billboard bool
modulate Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

AddMesh(Mesh, Material, Transform3D?, SkinReference)

Adds a mesh to the gizmo with the specified material, local transform and skeleton. Call this method during _Redraw().

public void AddMesh(Mesh mesh, Material material = null, Transform3D? transform = null, SkinReference skeleton = null)

Parameters

mesh Mesh
material Material
transform Transform3D?

If the parameter is null, then the default value is Transform3D.Identity.

skeleton SkinReference

AddUnscaledBillboard(Material, float, Color?)

Adds an unscaled billboard for visualization and selection. Call this method during _Redraw().

public void AddUnscaledBillboard(Material material, float defaultScale = 1, Color? modulate = null)

Parameters

material Material
defaultScale float
modulate Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

Clear()

Removes everything in the gizmo including meshes, collisions and handles.

public void Clear()

GetNode3D()

Returns the Node3D node associated with this gizmo.

public Node3D GetNode3D()

Returns

Node3D

GetPlugin()

Returns the EditorNode3DGizmoPlugin that owns this gizmo. It's useful to retrieve materials using GetMaterial(string, EditorNode3DGizmo).

public EditorNode3DGizmoPlugin GetPlugin()

Returns

EditorNode3DGizmoPlugin

GetSubgizmoSelection()

Returns a list of the currently selected subgizmos. Can be used to highlight selected elements during _Redraw().

public int[] GetSubgizmoSelection()

Returns

int[]

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsSubgizmoSelected(int)

Returns true if the given subgizmo is currently selected. Can be used to highlight selected elements during _Redraw().

public bool IsSubgizmoSelected(int id)

Parameters

id int

Returns

bool

SetHidden(bool)

Sets the gizmo's hidden state. If true, the gizmo will be hidden. If false, it will be shown.

public void SetHidden(bool hidden)

Parameters

hidden bool

SetNode3D(Node)

Sets the reference Node3D node for the gizmo. node must inherit from Node3D.

public void SetNode3D(Node node)

Parameters

node Node

_BeginHandleAction(int, bool)

public virtual void _BeginHandleAction(int id, bool secondary)

Parameters

id int
secondary bool

_CommitHandle(int, bool, Variant, bool)

Override this method to commit a handle being edited (handles must have been previously added by AddHandles(Vector3[], Material, int[], bool, bool)). 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 AddHandles(Vector3[], Material, int[], bool, bool) for more information).

public virtual void _CommitHandle(int id, bool secondary, Variant restore, bool cancel)

Parameters

id int
secondary bool
restore Variant
cancel bool

_CommitSubgizmos(int[], Array<Transform3D>, bool)

Override this method to commit a group of subgizmos being edited (see _SubgizmosIntersectRay(Camera3D, Vector2) and _SubgizmosIntersectFrustum(Camera3D, Array<Plane>)). 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.

public virtual void _CommitSubgizmos(int[] ids, Array<Transform3D> restores, bool cancel)

Parameters

ids int[]
restores Array<Transform3D>
cancel bool

_GetHandleName(int, bool)

Override this method to return the name of an edited handle (handles must have been previously added by AddHandles(Vector3[], Material, int[], bool, bool)). Handles can be named for reference to the user when editing.

The secondary argument is true when the requested handle is secondary (see AddHandles(Vector3[], Material, int[], bool, bool) for more information).

public virtual string _GetHandleName(int id, bool secondary)

Parameters

id int
secondary bool

Returns

string

_GetHandleValue(int, bool)

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 _CommitHandle(int, bool, Variant, bool).

The secondary argument is true when the requested handle is secondary (see AddHandles(Vector3[], Material, int[], bool, bool) for more information).

public virtual Variant _GetHandleValue(int id, bool secondary)

Parameters

id int
secondary bool

Returns

Variant

_GetSubgizmoTransform(int)

Override this method to return the current transform of a subgizmo. This transform will be requested at the start of an edit and used as the restore argument in _CommitSubgizmos(int[], Array<Transform3D>, bool).

public virtual Transform3D _GetSubgizmoTransform(int id)

Parameters

id int

Returns

Transform3D

_IsHandleHighlighted(int, bool)

Override this method to return true whenever the given handle should be highlighted in the editor.

The secondary argument is true when the requested handle is secondary (see AddHandles(Vector3[], Material, int[], bool, bool) for more information).

public virtual bool _IsHandleHighlighted(int id, bool secondary)

Parameters

id int
secondary bool

Returns

bool

_Redraw()

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.

public virtual void _Redraw()

_SetHandle(int, bool, Camera3D, Vector2)

Override this method to update the node properties when the user drags a gizmo handle (previously added with AddHandles(Vector3[], Material, int[], bool, bool)). The provided point 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 AddHandles(Vector3[], Material, int[], bool, bool) for more information).

public virtual void _SetHandle(int id, bool secondary, Camera3D camera, Vector2 point)

Parameters

id int
secondary bool
camera Camera3D
point Vector2

_SetSubgizmoTransform(int, Transform3D)

Override this method to update the node properties during subgizmo editing (see _SubgizmosIntersectRay(Camera3D, Vector2) and _SubgizmosIntersectFrustum(Camera3D, Array<Plane>)). The transform is given in the Node3D's local coordinate system.

public virtual void _SetSubgizmoTransform(int id, Transform3D transform)

Parameters

id int
transform Transform3D

_SubgizmosIntersectFrustum(Camera3D, Array<Plane>)

Override this method to allow selecting subgizmos using mouse drag box selection. Given a camera and a frustum, this method should return which subgizmos are contained within the frustum. The frustum 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, which can have any non-negative value and will be used in other virtual methods like _GetSubgizmoTransform(int) or _CommitSubgizmos(int[], Array<Transform3D>, bool).

public virtual int[] _SubgizmosIntersectFrustum(Camera3D camera, Array<Plane> frustum)

Parameters

camera Camera3D
frustum Array<Plane>

Returns

int[]

_SubgizmosIntersectRay(Camera3D, Vector2)

Override this method to allow selecting subgizmos using mouse clicks. Given a camera and a point 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 _GetSubgizmoTransform(int) or _CommitSubgizmos(int[], Array<Transform3D>, bool).

public virtual int _SubgizmosIntersectRay(Camera3D camera, Vector2 point)

Parameters

camera Camera3D
point Vector2

Returns

int