Fun With Prefabs, TileFabs, and Bundles
Interesting ways to use this system which are non-obvious.
Prefabs
In Paint mode, the center column has an option checkbox called: Bundle Tiles View. This checkbox only appears if the “Show Tile Bundles” checkbox is checked.
When unchecked, the Bundle is painted as a single item as usual.
When Bundle Tiles View is checked, the tiles and prefabs from a Bundle are displayed in a list and can be painted individually. When showing Bundles as a list, prefabs in the Bundle can be painted as if you were viewing a Palette of Prefabs.
You can use transform modification shortcuts like ALT+V, ALT+R/T/X/C/Z when previewing Prefabs.
You can also use the presets in the Painter Modifications editor window individually or as a default preset, as discussed in that section.
These changes do not affect Project folder Prefabs asset at all: when you release the mouse button, a copy of the asset is instantiated, has its transform modified (if only to set the position) and then painted.
The only way to affect the Z-position of a Prefab prior to painting it with a Painter Modification preset.
It’s important to note that the preview you see when painting a prefab is an “asset preview,” like the preview seen in an inspector. It’s entirely possible to use the ALT key shortcuts or a Painter Modification preset to create a transform that’ll place the prefab at a position and/or rotation that’d be invisible when the Scene view is in 2D mode. If it appears that your prefab disappears when you paint it, that’s probably what happened.
The Modifications Editor presets allow you to modify the offset from the mouse position, modify the scale, and/or modify the rotation by selecting one of the listed transforms and clicking ALT+V to modify the transform during Preview.
An unmodified transform will paint at the center of the tile cell.
Here’s an example of how to use this productively by creating a Prefabs palette:
- Create a new 2D Scene and add a Tilemap.
- Add all the Prefabs that you want to paint as children of that Tilemap.
- Ensure that they are parented to that single Tilemap.
- Change Painter’s mode to Grid Selection (the third mode button), select the Tilemap with the child prefabs in Painter’s left column, and use the Marquee Shortcut key to draw a marquee around the area that you want to save, click the Grid Selection button, then click the Create Bundle button.
- This will guide you to create a Tile Bundle. The Bundle won’t have any tiles (unless you have painted some) but will have the Prefab references.
If you view this new Bundle in Painter with Bundle Tiles View checked, you can select and paint the prefabs as if this were a Palette of prefabs or you can paint the Bundle all at once, as usual, as sort of a mega-prefab.
Here's the list-view of a (trivial) bundle quickly created using the above process.
For quick Prefab painting, just select one or more Prefabs in a Project folder and use the TilePlus/Add To Painter Favorites context menu item.
An easier approach is to multiple-select Prefabs in a Project folder and use the TilePlus/Bundle Project Prefabs context menu item. This will create a Bundle that you can view in Painter with the Bundle Tiles View toggle set ON and allow you to paint the Prefabs individually. Note that this bundle has fixed positioning of the Prefabs and hence it has limited use: it won’t make sense to paint the entire Bundle. Bundles captured from the scene preserve the transform settings of the Prefab as set in the scene.
Previewing Prefabs
When previewing a Bundle (including previewing a TileFab, which is just a collection of Bundles) up to 128 prefabs can be previewed in total, per preview cycle (which happens several times per second depending on how fast you move the mouse). So, if you have a TileFab with several Bundles and the total number of Prefabs in all the Bundles is greater than 128 then some of the bundled Prefabs won’t preview.
Aside from that, you can preview and paint Bundles (when the Bundle Tiles View option is unchecked) and TileFabs with embedded Prefabs. The preview works the same as described above: they’re asset previews. The only difference is that the transform modification shortcuts are inoperative on groups of prefabs.
One advantage of using Bundles for prefabs is that any transform changes such as rotation and scale are preserved and then restored when the Bundle’s prefabs are painted via Painter or calls to the TileFabLib library. Transform changes don’t show in the preview, and the positioning during preview may be slightly incorrect due to integer math issues.
Prefabs and GridSelection
If there’s a Grid Selection when using the Paint tool and the current Object is a Prefab AND you click into the Grid Selection then the entire selection will be filled with the Prefab, with transform modifications applied if done during preview (when moving the mouse) via a shortcut key.
Additionally, an area fill of Prefabs occurs if you drag out a marquee using the Marquee Shortcut key.
These actions mimic what’s done with tiles.
Erasing or Modifying Prefabs
The Erase tool can’t be used to delete Prefabs in a scene, nor can the Rotate and Flip tools be used on Prefabs in a scene. Once placed in a scene, all further editing must be performed using normal Unity tools for GameObjects.
The only exception is when using the “TilePlus Clear Tilemaps” function from the Tools menu, from the context menu, or via the Clear Tilemaps button in the Grid Selection panel as that function erases all tiles and parented GameObjects in the entire Tilemap or group of Tilemaps.
Decomposing a TileSet
Perhaps you have a TileSet that you bought on the Asset Store, Itch.io or somewhere like that. Often you need to paint more than one tile from such a set to create a complete visual object in the scene: a building might comprise a dozen or more tiles or something smaller like a sign might take two or three tiles.
If you’ve used the TileSet to create a Unity Palette, you can use the UTE or Painter’s Palette display to select a group in the palette and paint it – but you must recreate this selection every time (although 2023.X / Unity 6 versions include a “brush picks” overlay which improves the situation somewhat).
When you use the Painter’s built-in Palette display and select a group of tiles from a Palette, they comprise what’s called a “Multiple-Selection” and that’s shown as an eyedropper icon in the Clipboard.
It might not be obvious, but the Palette display is actually a Tilemap, so a Multiple Selection from a Palette is the same as a Multiple Selection from a Tilemap in the Scene View.
If you have a Multiple Selection, you might only need it for a short while. In Painter, you can save the Multiple Selection to Favorites, make a Bundle of the selection, or even create a single tile that will load the bundle when it is painted on a Tilemap.
Here’s a simple workflow to create Picks and save them in Bundles.
- Examine a Palette in Painter with the Use Unity Palette option checkbox ON.
- Drag-select a group of tiles.
- The eyedropper image appears in the Clipboard.
- Click the B button and follow the prompts.
If you don’t want to create a Bundle, you can always click F instead. That will preserve the Pick in Favorites, which is persistent between Unity Editor sessions. Pro tip: if you select the Pick from Favorites you can click B to Bundle it later!
In either case, an Icon is generated. (see: About the Icon).
The Bundle will be initially set up to be visible to Painter so that it appears in the list of Sources.
See “What’s a TpBundleTile?” to find out how to create a tile proxy for the Bundle.
TileFabs as Snippets
You can use TileFabs to create 'snippets' of tiles which can be painted using Painter.
In the Layout demo's DesignTileFabs folder you can see a few prebuilt buildings that can be dropped into any tilemap with matching Tilemap names.
These were created directly from the Scene View using a Grid Selection. Note that all tilemap layers with any tiles or (parented) prefabs are archived. You'll notice that the three TileFabs in this folder all have three bundles.
Think of it as a template or a sort-of-prefab.