EditorNode3DGizmoPlugin

package
v0.0.0-...-e10d1cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

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.AddNode3dGizmoPlugin method first.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsEditorNode3DGizmoPlugin() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsEditorNode3DGizmoPlugin

func (self *Extension[T]) AsEditorNode3DGizmoPlugin() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.EditorNode3DGizmoPlugin

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func Get

Returns the [EditorNode3DGizmoPlugin] that owns this gizmo. It's useful to retrieve materials using [method EditorNode3DGizmoPlugin.get_material].

func New

func New() Instance

func (Instance) AddMaterial

func (self Instance) AddMaterial(name string, material StandardMaterial3D.Instance)

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

func (Instance) AsEditorNode3DGizmoPlugin

func (self Instance) AsEditorNode3DGizmoPlugin() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) CreateHandleMaterial

func (self Instance) CreateHandleMaterial(name string)

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 and used in EditorNode3DGizmo.AddHandles. Should not be overridden.

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

func (Instance) CreateIconMaterial

func (self Instance) CreateIconMaterial(name string, texture Texture2D.Instance)

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 and used in EditorNode3DGizmo.AddUnscaledBillboard. Should not be overridden.

func (Instance) CreateMaterial

func (self Instance) CreateMaterial(name string, color Color.RGBA)

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 and used in EditorNode3DGizmo.AddMesh and EditorNode3DGizmo.AddLines. Should not be overridden.

func (Instance) GetMaterial

func (self Instance) GetMaterial(name string) StandardMaterial3D.Instance

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

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type Interface

type Interface interface {
	// 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.
	//
	// [EditorNode3DGizmo]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmo
	// [Node3D]: https://pkg.go.dev/graphics.gd/classdb/Node3D
	HasGizmo(for_node_3d Node3D.Instance) bool
	// Override this method to return a custom [EditorNode3DGizmo] for the 3D nodes of your choice, return null for the rest of nodes. See also [HasGizmo].
	//
	// [EditorNode3DGizmo]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmo
	// [HasGizmo]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	CreateGizmo(for_node_3d Node3D.Instance) EditorNode3DGizmo.Instance
	// Override this method to provide the name that will appear in the gizmo visibility menu.
	GetGizmoName() string
	// 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.
	GetPriority() int
	// Override this method to define whether the gizmos handled by this plugin can be hidden or not. Returns true if not overridden.
	CanBeHidden() bool
	// Override this method to define whether Node3D with this gizmo should be selectable even when the gizmo is hidden.
	IsSelectableWhenHidden() bool
	// 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.
	//
	// [EditorNode3DGizmo.Clear]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmo#Instance.Clear
	Redraw(gizmo EditorNode3DGizmo.Instance)
	// Override this method to provide gizmo's handle names. The 'secondary' argument is true when the requested handle is secondary (see [EditorNode3DGizmo.AddHandles] for more information). Called for this plugin's active gizmos.
	//
	// [EditorNode3DGizmo.AddHandles]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmo#Instance.AddHandles
	GetHandleName(gizmo EditorNode3DGizmo.Instance, handle_id int, secondary bool) string
	// 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.AddHandles] for more information). Called for this plugin's active gizmos.
	//
	// [EditorNode3DGizmo.AddHandles]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmo#Instance.AddHandles
	IsHandleHighlighted(gizmo EditorNode3DGizmo.Instance, handle_id int, secondary bool) 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].
	//
	// The 'secondary' argument is true when the requested handle is secondary (see [EditorNode3DGizmo.AddHandles] for more information).
	//
	// Called for this plugin's active gizmos.
	//
	// [CommitHandle]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	// [EditorNode3DGizmo.AddHandles]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmo#Instance.AddHandles
	GetHandleValue(gizmo EditorNode3DGizmo.Instance, handle_id int, secondary bool) any
	BeginHandleAction(gizmo EditorNode3DGizmo.Instance, handle_id int, secondary bool)
	// Override this method to update the node's properties when the user drags a gizmo handle (previously added with [EditorNode3DGizmo.AddHandles]). 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.AddHandles] for more information).
	//
	// Called for this plugin's active gizmos.
	//
	// [EditorNode3DGizmo.AddHandles]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmo#Instance.AddHandles
	SetHandle(gizmo EditorNode3DGizmo.Instance, handle_id int, secondary bool, camera Camera3D.Instance, screen_pos Vector2.XY)
	// Override this method to commit a handle being edited (handles must have been previously added by [EditorNode3DGizmo.AddHandles] 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.AddHandles] for more information).
	//
	// Called for this plugin's active gizmos.
	//
	// [EditorNode3DGizmo.AddHandles]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmo#Instance.AddHandles
	// [Redraw]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	// [UndoRedo]: https://pkg.go.dev/graphics.gd/classdb/UndoRedo
	CommitHandle(gizmo EditorNode3DGizmo.Instance, handle_id int, secondary bool, restore any, cancel bool)
	// 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 [GetSubgizmoTransform] or [CommitSubgizmos]. Called for this plugin's active gizmos.
	//
	// [CommitSubgizmos]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	// [GetSubgizmoTransform]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	SubgizmosIntersectRay(gizmo EditorNode3DGizmo.Instance, camera Camera3D.Instance, screen_pos Vector2.XY) int
	// 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 [Plane.NormalD]s 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] or [CommitSubgizmos]. Called for this plugin's active gizmos.
	//
	// [CommitSubgizmos]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	// [GetSubgizmoTransform]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	// [Plane.NormalD]: https://pkg.go.dev/graphics.gd/variant/Plane#NormalD
	SubgizmosIntersectFrustum(gizmo EditorNode3DGizmo.Instance, camera Camera3D.Instance, frustum_planes []Plane.NormalD) []int32
	// 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]. Called for this plugin's active gizmos.
	//
	// [CommitSubgizmos]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	GetSubgizmoTransform(gizmo EditorNode3DGizmo.Instance, subgizmo_id int) Transform3D.BasisOrigin
	// Override this method to update the node properties during subgizmo editing (see [SubgizmosIntersectRay] and [SubgizmosIntersectFrustum]). The 'transform' is given in the Node3D's local coordinate system. Called for this plugin's active gizmos.
	//
	// [SubgizmosIntersectFrustum]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	// [SubgizmosIntersectRay]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	SetSubgizmoTransform(gizmo EditorNode3DGizmo.Instance, subgizmo_id int, transform Transform3D.BasisOrigin)
	// Override this method to commit a group of subgizmos being edited (see [SubgizmosIntersectRay] and [SubgizmosIntersectFrustum]). 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.
	//
	// [SubgizmosIntersectFrustum]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	// [SubgizmosIntersectRay]: https://pkg.go.dev/graphics.gd/classdb/EditorNode3DGizmoPlugin#Interface
	// [UndoRedo]: https://pkg.go.dev/graphics.gd/classdb/UndoRedo
	CommitSubgizmos(gizmo EditorNode3DGizmo.Instance, ids []int32, restores []Transform3D.BasisOrigin, cancel bool)
}

type MoreArgs

type MoreArgs [1]gdclass.EditorNode3DGizmoPlugin

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) CreateHandleMaterial

func (self MoreArgs) CreateHandleMaterial(name string, billboard bool, texture Texture2D.Instance)

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 and used in EditorNode3DGizmo.AddHandles. Should not be overridden.

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

func (MoreArgs) CreateIconMaterial

func (self MoreArgs) CreateIconMaterial(name string, texture Texture2D.Instance, on_top bool, color Color.RGBA)

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 and used in EditorNode3DGizmo.AddUnscaledBillboard. Should not be overridden.

func (MoreArgs) CreateMaterial

func (self MoreArgs) CreateMaterial(name string, color Color.RGBA, billboard bool, on_top bool, use_vertex_color 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 and used in EditorNode3DGizmo.AddMesh and EditorNode3DGizmo.AddLines. Should not be overridden.

func (MoreArgs) GetMaterial

func (self MoreArgs) GetMaterial(name string, gizmo EditorNode3DGizmo.Instance) StandardMaterial3D.Instance

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL