EditorShapes
EditorShapes is a small plugin for Godot 4.X that allows you to define shapes directly in the editor for drawing or logic purposes.
The main advantage of this plugin is that every node in Godot that allows you to define a shape and edit it by dragging its handles is either a physics based node or a Control node that doesn't inherit from the Node2D hierarchy. This plugin adds that same functionality, with a Node2D based node that doesn't implement any physics behaviour.
⚠ Warning: This is a very early version of the plugin. Although it works well and has been tested, expect breaking changes in future updates. Any breaking changes will be listed in the changelog.
Features
Works like a built-in editable shape
The plugin allows you to drag the shape from each corner and side. Holding Alt makes it extend in both directions. Holding Ctrl/Command keeps it square.
Snap to grid, customizable for each node
Set the snap grid size for each node, or share the same configuration between multiple nodes by using a shared resource.
Customize editor colors and make the shape visible at runtime
You can set custom colors for the shape's outline and handles in the editor. You can also make the shape visible at runtime, giving it a similar visual role to a ColorRect while keeping it within the Node2D hierarchy.
Create masks
Add a mask that makes the shape invisible within a defined area. A mask node doesn't necessarily need to be a child of the masked node; it can be placed anywhere in the scene tree.
How to use
The plugin is straightforward to use. To define a shape, simply add a RectangleZone2D node to your scene.
Customization
- Add a resource to the
Zone Configurationproperty. If no resource is assigned, the node will use a default configuration. - To make the shape visible at runtime, set the
Visible on Runtimeproperty totrue. You can also change theColorproperty. - If you set
Always Visibletotrue, the shape's outline will always be visible in the editor, even when neither the node nor one of its direct parents is selected. - You can tweak the remaining properties to configure snapping and editor visibility.
Masking
- Add a
RectangleMaskZone2Dnode to your scene. - If you make it a direct child of a
RectangleZone2Dnode, it will mask that node. - Alternatively, you can add one or more
RectangleZone2Dnodes to theMasked Zonesarray to mask those shapes.
Roadmap
Add an option to choose the masking mode
Currently, these shapes are rendered using the _draw() function. If a mask is added to a shape, it is split into several rectangles, each of which is created by calling _draw_rect(). The reason for this, instead of using a shader, is that some devices without a dedicated GPU can struggle when rendering shaders, even when they are as simple as a rectangle mask.
In a future update, I want to give users the option to choose the rendering mode, either through the Inspector or programmatically, so they can choose which method is used.
Make a resource-based editable shape
Although Godot already has resource-based shapes (RectangleShape2D, CircleShape2D, etc.), these are physics-based. I don't think this has a significant impact on performance or makes the editor cumbersome, but I'd like to provide the same customization options whether the shape is rendered by the node itself or through a resource.
Add circle and polygon shapes
Circle shapes are definitely something I want to add, along with the ability to mask rectangles with circles and vice versa.
Polygons, on the other hand, are a bit more complicated. Godot already has a Node2D-based polygon node, so I might simply extend it to allow it to be masked or to mask other shapes.
FAQ
Can I undo / redo my changes?
Yes. The plugin uses Godot's undo/redo system, so any changes you make to a shape will be properly registered.
Will you expand this plugin to support other shapes?
Yes. I plan to add support for circle shapes. For polygon shapes, I might find a way to add masking support using the existing Polygon2D node.
I added a mask, but it's not visible in the editor
Unfortunately, dynamically adding masks is still a feature I want to implement, but haven't had time to. The same applies to adding or modifying masks at runtime.
Changelog for version v0.1.0
No changelog provided for this version.