Class EditorNode3DGizmoPlugin
- Namespace
- Godot
- Assembly
- GodotSharpEditor.dll
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 AddNode3DGizmoPlugin(EditorNode3DGizmoPlugin) method first.
public class EditorNode3DGizmoPlugin : Resource, IDisposable
- Inheritance
-
EditorNode3DGizmoPlugin
- Implements
- Inherited Members
Constructors
EditorNode3DGizmoPlugin()
public EditorNode3DGizmoPlugin()
Methods
AddMaterial(string, StandardMaterial3D)
Adds a new material to the internal material list for the plugin. It can then be accessed with GetMaterial(string, EditorNode3DGizmo). Should not be overridden.
public void AddMaterial(string name, StandardMaterial3D material)
Parameters
namestringmaterialStandardMaterial3D
CreateHandleMaterial(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 GetMaterial(string, EditorNode3DGizmo) and used in AddHandles(Vector3[], Material, int[], bool, bool). Should not be overridden.
You can optionally provide a texture to use instead of the default icon.
public void CreateHandleMaterial(string name, bool billboard = false, Texture2D texture = null)
Parameters
CreateIconMaterial(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 GetMaterial(string, EditorNode3DGizmo) and used in AddUnscaledBillboard(Material, float, Color?). Should not be overridden.
public void CreateIconMaterial(string name, Texture2D texture, bool onTop = false, Color? color = null)
Parameters
namestringtextureTexture2DonTopboolcolorColor?If the parameter is null, then the default value is
new Color(1, 1, 1, 1).
CreateMaterial(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 GetMaterial(string, EditorNode3DGizmo) and used in AddMesh(Mesh, Material, Transform3D?, SkinReference) and AddLines(Vector3[], Material, bool, Color?). Should not be overridden.
public void CreateMaterial(string name, Color color, bool billboard = false, bool onTop = false, bool useVertexColor = false)
Parameters
GetMaterial(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).
public StandardMaterial3D GetMaterial(string name, EditorNode3DGizmo gizmo = null)
Parameters
namestringgizmoEditorNode3DGizmo
Returns
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
methodgodot_string_nameName of the method to check for.
Returns
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
signalgodot_string_nameName of the signal to check for.
Returns
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
methodgodot_string_nameName of the method to invoke.
argsNativeVariantPtrArgsArguments to use with the invoked method.
retgodot_variantValue returned by the invoked method.
Returns
_BeginHandleAction(EditorNode3DGizmo, int, bool)
public virtual void _BeginHandleAction(EditorNode3DGizmo gizmo, int handleId, bool secondary)
Parameters
gizmoEditorNode3DGizmohandleIdintsecondarybool
_CanBeHidden()
Override this method to define whether the gizmos handled by this plugin can be hidden or not. Returns true if not overridden.
public virtual bool _CanBeHidden()
Returns
_CommitHandle(EditorNode3DGizmo, 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) during _Redraw(EditorNode3DGizmo)). 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).
Called for this plugin's active gizmos.
public virtual void _CommitHandle(EditorNode3DGizmo gizmo, int handleId, bool secondary, Variant restore, bool cancel)
Parameters
gizmoEditorNode3DGizmohandleIdintsecondaryboolrestoreVariantcancelbool
_CommitSubgizmos(EditorNode3DGizmo, int[], Array<Transform3D>, bool)
Override this method to commit a group of subgizmos being edited (see _SubgizmosIntersectRay(EditorNode3DGizmo, Camera3D, Vector2) and _SubgizmosIntersectFrustum(EditorNode3DGizmo, 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. As with all subgizmo methods, transforms are given in local space respect to the gizmo's Node3D. Called for this plugin's active gizmos.
public virtual void _CommitSubgizmos(EditorNode3DGizmo gizmo, int[] ids, Array<Transform3D> restores, bool cancel)
Parameters
gizmoEditorNode3DGizmoidsint[]restoresArray<Transform3D>cancelbool
_CreateGizmo(Node3D)
Override this method to return a custom EditorNode3DGizmo for the spatial nodes of your choice, return null for the rest of nodes. See also _HasGizmo(Node3D).
public virtual EditorNode3DGizmo _CreateGizmo(Node3D forNode3D)
Parameters
forNode3DNode3D
Returns
_GetGizmoName()
Override this method to provide the name that will appear in the gizmo visibility menu.
public virtual string _GetGizmoName()
Returns
_GetHandleName(EditorNode3DGizmo, int, bool)
Override this method to provide gizmo's handle names. The secondary argument is true when the requested handle is secondary (see AddHandles(Vector3[], Material, int[], bool, bool) for more information). Called for this plugin's active gizmos.
public virtual string _GetHandleName(EditorNode3DGizmo gizmo, int handleId, bool secondary)
Parameters
gizmoEditorNode3DGizmohandleIdintsecondarybool
Returns
_GetHandleValue(EditorNode3DGizmo, 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(EditorNode3DGizmo, 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).
Called for this plugin's active gizmos.
public virtual Variant _GetHandleValue(EditorNode3DGizmo gizmo, int handleId, bool secondary)
Parameters
gizmoEditorNode3DGizmohandleIdintsecondarybool
Returns
_GetPriority()
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.
public virtual int _GetPriority()
Returns
_GetSubgizmoTransform(EditorNode3DGizmo, int)
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 _CommitSubgizmos(EditorNode3DGizmo, int[], Array<Transform3D>, bool). Called for this plugin's active gizmos.
public virtual Transform3D _GetSubgizmoTransform(EditorNode3DGizmo gizmo, int subgizmoId)
Parameters
gizmoEditorNode3DGizmosubgizmoIdint
Returns
_HasGizmo(Node3D)
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.
public virtual bool _HasGizmo(Node3D forNode3D)
Parameters
forNode3DNode3D
Returns
_IsHandleHighlighted(EditorNode3DGizmo, int, 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 AddHandles(Vector3[], Material, int[], bool, bool) for more information). Called for this plugin's active gizmos.
public virtual bool _IsHandleHighlighted(EditorNode3DGizmo gizmo, int handleId, bool secondary)
Parameters
gizmoEditorNode3DGizmohandleIdintsecondarybool
Returns
_IsSelectableWhenHidden()
Override this method to define whether Node3D with this gizmo should be selectable even when the gizmo is hidden.
public virtual bool _IsSelectableWhenHidden()
Returns
_Redraw(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.
public virtual void _Redraw(EditorNode3DGizmo gizmo)
Parameters
gizmoEditorNode3DGizmo
_SetHandle(EditorNode3DGizmo, int, bool, Camera3D, Vector2)
Override this method to update the node's properties when the user drags a gizmo handle (previously added with AddHandles(Vector3[], Material, int[], bool, bool)). The provided screenPos 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).
Called for this plugin's active gizmos.
public virtual void _SetHandle(EditorNode3DGizmo gizmo, int handleId, bool secondary, Camera3D camera, Vector2 screenPos)
Parameters
gizmoEditorNode3DGizmohandleIdintsecondaryboolcameraCamera3DscreenPosVector2
_SetSubgizmoTransform(EditorNode3DGizmo, int, Transform3D)
Override this method to update the node properties during subgizmo editing (see _SubgizmosIntersectRay(EditorNode3DGizmo, Camera3D, Vector2) and _SubgizmosIntersectFrustum(EditorNode3DGizmo, Camera3D, Array<Plane>)). The transform is given in the Node3D's local coordinate system. Called for this plugin's active gizmos.
public virtual void _SetSubgizmoTransform(EditorNode3DGizmo gizmo, int subgizmoId, Transform3D transform)
Parameters
gizmoEditorNode3DGizmosubgizmoIdinttransformTransform3D
_SubgizmosIntersectFrustum(EditorNode3DGizmo, Camera3D, Array<Plane>)
Override this method to allow selecting subgizmos using mouse drag box selection. Given a camera and frustumPlanes, this method should return which subgizmos are contained within the frustums. The frustumPlanes 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 _GetSubgizmoTransform(EditorNode3DGizmo, int) or _CommitSubgizmos(EditorNode3DGizmo, int[], Array<Transform3D>, bool). Called for this plugin's active gizmos.
public virtual int[] _SubgizmosIntersectFrustum(EditorNode3DGizmo gizmo, Camera3D camera, Array<Plane> frustumPlanes)
Parameters
gizmoEditorNode3DGizmocameraCamera3DfrustumPlanesArray<Plane>
Returns
- int[]
_SubgizmosIntersectRay(EditorNode3DGizmo, Camera3D, Vector2)
Override this method to allow selecting subgizmos using mouse clicks. Given a camera and a screenPos 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(EditorNode3DGizmo, int) or _CommitSubgizmos(EditorNode3DGizmo, int[], Array<Transform3D>, bool). Called for this plugin's active gizmos.
public virtual int _SubgizmosIntersectRay(EditorNode3DGizmo gizmo, Camera3D camera, Vector2 screenPos)
Parameters
gizmoEditorNode3DGizmocameraCamera3DscreenPosVector2