A simple flex container plugin for Godot.
- Download the latest version in releases or clone the repository.
- Copy the contents of
addons/FlexContainerinto yourres://addons/FlexContainerdirectory. - Enable
Dialogue Managerin your project plugins.
- Set a grid size using the
ColumnsandRowsinInspector. - In
Inspectorincrease the amount ofVector2inBlocksproperty based on the grid size (Columns×Rows).
This is not required but recommended. It would also be better to avoid going beyond grid size. Vector2'sxacts as span whileyacts as row. Customize them depending to your need.- Added children within the node will change size and position corresponding to the
Vector2inBlocks.
The firstVector2corresponds to the first child and so forth.
Note: when extending the script, add the tool keyword to have the exports show in the Inspector.
| Property | Type | Definition |
|---|---|---|
| Columns | int | the width or amount of column the container will have, forming a grid. |
| Rows | int | the height or amount of rows the container will have, forming a grid. |
| Blocks | PoolVector2Array | the placeholder for child nodes within the container. Each Vector2 represents a block within a grid, having its own span (x) and row (y). It moves from left to right and top to bottom. |
| Compact | boolean | it fills in the empty spaces within the container. |
| Limit Visible | boolean | it hides children that goes beyond the container's size or outside the size of Blocks. |
| Disable Min Size | boolean | it sets the rect_min_size of children to Vector2.ZERO. This is currently the default as the container can't handle rect_min_size of children. |
- I suggest using DockableContainer for a more cleaner and flexible alternative. It does what FlexContainer does but more! Worth a try.
- Currently has no way to properly handle
rect_min_sizeof chilren. - Adding non
Controltype nodes may cause errors or even a crash. Bypass by encapsulating it inside a control type node. - Resizing isn't fully accurate which may cause some jitter and a pixel or two of misalignment. It's annoying.
Said issues may be fixed in the future updates. However, if you know a way to fix it, do open up an issue or a pull request. Your contribution would be greatly appreciated.