Add documentation for how to use CanvasItemGizmoPlugins#11853
Draft
derkork wants to merge 3 commits intogodotengine:masterfrom
Draft
Add documentation for how to use CanvasItemGizmoPlugins#11853derkork wants to merge 3 commits intogodotengine:masterfrom
derkork wants to merge 3 commits intogodotengine:masterfrom
Conversation
13 tasks
AThousandShips
requested changes
Mar 17, 2026
Member
AThousandShips
left a comment
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
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: | ||
|
|
||
| :: | ||
|
|
Member
There was a problem hiding this comment.
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: |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
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) |
Member
There was a problem hiding this comment.
Suggested change
| gizmo.add_collision_polygon(circle_polygon) | |
| gizmo.add_collision_polygon(circle_polygon) |
|
|
||
| # ... collision shapes code ... | ||
|
|
||
| # Add a handle for the radius |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
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() |
Member
There was a problem hiding this comment.
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 | ||
| ) |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.