Skip to content

Add documentation for how to use CanvasItemGizmoPlugins#11853

Draft
derkork wants to merge 3 commits intogodotengine:masterfrom
derkork:proposal-1910
Draft

Add documentation for how to use CanvasItemGizmoPlugins#11853
derkork wants to merge 3 commits intogodotengine:masterfrom
derkork:proposal-1910

Conversation

@derkork
Copy link
Copy Markdown
Contributor

@derkork derkork commented Mar 17, 2026

This PR adds documentation for the new 2D gizmo plugins introduced in: godotengine/godot#112979. I'll keep this a draft until the PR is in a state to be merged.

Copy link
Copy Markdown
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial pass for basic style, will do a proofreading pass later


Setting up the gizmo plugin
----------------------------
To create a 2D gizmo plugin, we'll need two things: a gizmo plugin class that
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To create a 2D gizmo plugin, we'll need two things: a gizmo plugin class that
To create a 2D gizmo plugin, we'll need two things: a gizmo plugin class that

Let's start with the gizmo plugin class. Create a new script:

::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these should use .. code-blocks, see other pages for reference


func _get_gizmo_name() -> String:
return "Circle"
Let's look at these two methods:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Let's look at these two methods:
Let's look at these two methods:

--------------------

The outline rect control gives our node a visible boundary box and automatic scaling
handles, just like built-in nodes such as Sprite2D or ColorRect. This is useful when
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handles, just like built-in nodes such as Sprite2D or ColorRect. This is useful when
handles, just like built-in nodes such as ``Sprite2D`` or ``ColorRect``. This is useful when

for i: int in 16:
var angle: float = i * TAU / 16.0
circle_polygon.append(Vector2(cos(angle), sin(angle)) * circle.radius)
gizmo.add_collision_polygon(circle_polygon)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gizmo.add_collision_polygon(circle_polygon)
gizmo.add_collision_polygon(circle_polygon)


# ... collision shapes code ...

# Add a handle for the radius
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Add a handle for the radius
# Add a handle for the radius.

For all, per the comment style

# ... collision shapes code ...

# Add a handle for the radius
var handle_pos: Vector2 = Vector2(sin(PI/4.0), cos(PI/4.0)) * circle.radius
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var handle_pos: Vector2 = Vector2(sin(PI/4.0), cos(PI/4.0)) * circle.radius
var handle_pos: Vector2 = Vector2(sin(PI / 4.0), cos(PI / 4.0)) * circle.radius

var subgizmo_id: int = ids[i]
var old_transform: Transform2D = restores[i]
flower._petals[subgizmo_id] = old_transform
flower._repaint()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flower._repaint()
flower._repaint()

Comment on lines +541 to +544
circle_polygon.append(
(Vector2(cos(angle), sin(angle)) * circle.radius)
- circle.pivot # Offset by pivot
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
circle_polygon.append(
(Vector2(cos(angle), sin(angle)) * circle.radius)
- circle.pivot # Offset by pivot
)
circle_polygon.append(
Vector2(cos(angle), sin(angle)) * circle.radius \
- circle.pivot # Offset by pivot.
)

Continuation is indented twice, also needs continuation \ for expressions AFAIK (test to make sure)

Comment on lines +555 to +556
Vector2(sin(PI/4.0), cos(PI/4.0)) * circle.radius \
- circle.pivot
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Vector2(sin(PI/4.0), cos(PI/4.0)) * circle.radius \
- circle.pivot
Vector2(sin(PI / 4.0), cos(PI / 4.0)) * circle.radius \
- circle.pivot

@skyace65 skyace65 added enhancement area:manual Issues and PRs related to the Manual/Tutorials section of the documentation waiting on pr merge PRs that can't be merged until an engine PR is merged first labels Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:manual Issues and PRs related to the Manual/Tutorials section of the documentation enhancement waiting on pr merge PRs that can't be merged until an engine PR is merged first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants