TileFabs, Bundles, and Chunk Snapping
Recall that a Bundle (TpTileBundle) asset is an archive of a single Tilemap and a TileFab (TpTileFab) asset is a collection of Bundle assets.
To exxclude a TileFab or Bundle from Painter, inspect the project asset and set the IgnoreInPainter field to true in an Inspector.
A Bundle asset can be painted like any other tile asset, and you can see the preview as you move the mouse pointer. Painting one of these will overwrite any tiles on whatever map is selected in Painter.
Additionally, if the Bundle Tiles View option is checked, the Bundle’s tiles and Prefabs are displayed in a list, and you can paint any of these objects individually. For other interesting things that you can do with Bundles in Painter, see “Fun With Prefabs and Bundles.”
Using a TileFab is a bit trickier: if you examine one you’ll see that each Tilemap in the collection has a specification for the name of a Tilemap or a tag: these are taken from the GameObject parent of the Tilemap component when the TileFab is created.
The idea is that when you paint a TileFab you’re really painting on at least one, but more likely several Tilemaps at the same time with each Bundle referenced by a TileFab corresponding to a particular Tilemap.
However, the Painter has no way of knowing which Bundle is for a particular map in your scene. And you probably don’t want it to guess! Furthermore, the TileFab may have four Bundles, but your scene may have more or fewer than that.
If you select a TileFab in the center column when the window is in Paint mode, you’ll be presented with the names and tags specified in the TileFab. It’s up to you to ensure that they exist. Mismatches are just omitted from previews and Painting.
For example, if you have Scene Tilemaps named A and B but your TileFab has a collection of four Bundle assets with Tilemaps A, B, C, and D then only A and B will be previewed or painted. C and D will be ignored and neither previewed nor painted. If your scene only has Tilemaps named X and Y, then nothing will be previewed or painted.
So, the names or tags must match.
Note that when “Show TileFabs” is checked another toggle becomes visible: “Matches Only.” If that’s checked then only TileFabs which match named Tilemaps/Tags in the scene are shown in the center column list.
“Matches Only” isn’t perfect: if you have multiple scenes loaded with similar Tilemap names and tags you can end up painting a TileFab’s embedded Bundles into different scenes. Be careful.
If you’re using Chunk-Style TileFabs for painting, Chunk Snapping can be really useful: read on...
Chunk Snapping
The Painter Settings panel has three settings that enable Chunk Snapping.
Chunk snapping allows you to easily paint and erase equal-sized Chunks on a virtual grid, with snapping.
The Chunk Snapping checkbox enables the mode and locks the fields just below.
- Set the Chunk Size for Snapping field to the fixed size of the TileFabs that you want to paint (4,6,8…).
- Set the Chunk Snapping World Origin field to the Origin position for TileFab painting. Usually 0,0,0 is what you want.
The center column will show only Chunks (TileFabs) whose bounds are the correct size.
The only active Tools are Paint and Erase.
Two marquees appear while using those tools when Snapping is on:
- At the nearest Chunk location on the virtual grid.
- At the Mouse Position
Both are the same size as the Chunk dimensions. If this doesn’t match the Chunk dimensions then Chunk Size for Snapping doesn't really match the size of the Chunk (which must be square and of even dimensions e.g., 4x4, 6x6 etc.). If the positioning seems off, check that the World Origin is set properly.
When the mouse position is on the virtual grid defined by the Chunk Size and the World Origin:
- The two Marquees merge.
- The color of the Marquee will change.
- <G> appears at the beginning of the informational text string and the font becomes italicized.
When the mouse cursor isn’t on the virtual grid and you click, the Painter paints the Chunk in that nearest virtual grid location. The mouse cursor won’t move.
If you paint the same chunk at the same virtual grid location, then the area is erased first.
When using the Erase tool when Snapping is on, a TileFab that uses the same Tilemaps must be selected in the center column so that Erase knows which maps to erase. If that’s not the case, nothing happens, and a reminder dialog box will appear.
Erase deletes all tiles in the highlighted region. Any children of the Tilemaps’ GameObjects in that area are also deleted.
Erase requires that the mouse position be aligned with the virtual grid; watch the marquees and the <G>.
Show SGrid option
Show SGrid can be activated by a mini-toolbar button at the bottom of the window or from the Configuration panel (Gear icon).
- When checked the 'SGrid' (the super-grid using the 'Chunk Size For Snapping' setting) is visible in the scene as a box around the cursor location.
- It's handy when creating Tile Scenes using the layout system.
- There's a Color field just above the checkbox to customize the color.
- It's not shown if the Settings Panel Chunk Snapping toggle is on.