Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
An editor-only plugin for Godot 4.5+ that adds a real-time visual overlay to the inspector for NinePatchRect nodes, showing patch margins and stretchable regions.
NinePatch Margin Visualizer
🔭 Overview
The NinePatch Margin Visualizer is a Godot editor plugin designed to provide clear visual feedback for NinePatchRect nodes.
It solves common problems developers face when editing NinePatch textures: misunderstanding which areas of a texture are stretchable, confusing margin boundaries, and difficulty previewing how the texture behaves under resizing. This plugin offers a visual overlay in the inspector, making it immediately clear how each slice of the texture affects runtime stretching.
🚀 Features
Inspector Integration
- Seamlessly integrated into the Godot Editor Inspector.
- Appears automatically whenever you select a
NinePatchRectnode, providing immediate context without cluttering your workspace.
Smart Visualization
- Stretch Regions: Features a "Show Stretch Regions" toggle that overlays a hatched pattern on the stretchable areas of your texture.
- Blue Hatching: Indicates the central stretch region.
- Green/Yellow Hatching: Distinction between horizontal and vertical stretch zones helps you instantly verify your margin settings.
- Clear Boundaries: Draws precise lines indicating exactly where the patch margins slice your texture.
- Stretch Regions: Features a "Show Stretch Regions" toggle that overlays a hatched pattern on the stretchable areas of your texture.
Live Feedback
- Real-time updates as you modify
Patch Marginproperties (Left, Top, Right, Bottom). - Instantly see how changes affect the stretchable and fixed regions of your UI element.
- Real-time updates as you modify
Customizable UI
- Expanded View: Toggle between a compact preview and a larger detailed view to inspect fine details.
- Persistent Settings: Your preferences for view size and overlays are saved to
EditorSettings, remembering your setup across sessions.
Theme Aware
- Automatically adapts to your Editor's theme colors.
- High-contrast lines ensure visibility whether you are using a Light or Dark theme.
Zero Runtime Cost
- This is an Editor-Only plugin.
- All logic is contained within the editor; absolutely no code or overhead is added to your exported game.
🌱 Installation
Method 1: Asset Library (Recommended)
- Open the AssetLib tab in the Godot Editor.
- Search for "NinePatch Margin Visualizer".
- Click on the result and select Download.
- Once downloaded, click Install to add the files to your project.
- Go to Project -> Project Settings -> Plugins and enable the plugin.
Method 2: Manual Installation
- Download the latest release.
- Copy the
addons/ninepatch_margin_visualizerfolder into your project'saddons/directory. - Go to Project -> Project Settings -> Plugins.
- Enable NinePatch Margin Visualizer.
🎮 Usage
- Select any
NinePatchRectnode in your scene. - Look for the visualizer panel in the Inspector.
- Use the checkboxes in the top-left corner of the preview to:
- Toggle stretch-region overlays.
- Switch between compact and expanded views.
- Edit the
NinePatchRectproperties (Patch Margin); the preview will update live.
⚙️ Technical Details
This plugin uses an EditorInspectorPlugin to inject a custom control into the inspector whenever a NinePatchRect is edited.
NinePatchMarginVisualizer(EditorInspectorPlugin): Handles thecan_handlecallback to detectNinePatchRectnodes and instantiates the preview control.NinePatchMarginPreview(EditorProperty): The custom control that handles the drawing logic. It listens for property changes on the edited object and triggers a redraw of the margin lines and hatch patterns.- Smart Caching: Hatch patterns are generated procedurally to ensure they look crisp at any zoom level, but cached to minimize performance impact.
Note: This plugin is editor-only. It does not inject code into your exported game and has no impact on runtime performance.
🔎 Demo
A demo scene is included in demos/ninepatch_margin_visualizer/ for experimentation and testing. The demo shows a placeholder texture and allows live interaction with margin adjustments.
⚖️ License
This project is licensed under the MIT License - see the LICENSE file for details.
An editor-only plugin for Godot 4.5+ that adds a real-time visual overlay to the inspector for NinePatchRect nodes, showing patch margins and stretchable regions.
Reviews
Quick Information
An editor-only plugin for Godot 4.5+ that adds a real-time visual overlay to the inspector for NinePatchRect nodes, showing patch margins and stretchable regions.