Creating Prefab Brushes

Working with Animated Prefabs within Unity Tilemaps

Simon Truong
3 min readNov 11, 2021

--

Another useful function within the Unity Tilemaps is painting prefabs into the grid. This is useful for quickly placing repeatable objects within the grid without manually dragging and dropping them within the scene.

Creating the Prefab:

Before we can create a prefab, we first need to slice the image that contains our object. In this scenario we will be using a Diamond as an collectable object, and being able to paint that object quickly on my scene would speed up the process.

Slice the object into the total desired amount

Then drag one diamond image into the scene view. Resize the diamond object to fit within one cell size of the grid. Create a folder called “Prefabs” within the assets folder and drag the diamond into this folder, Unity will automatically create a Prefab object for that diamond.

Creating the Custom Brush:

Create a new folder within the Tilemap folder and name this folder “Brushes”. Within this folder we are going to right click > Create > 2D > Brushes > Prefab Brush.

Once you have created the custom brush object, within the hierarchy we can drag and drop the prefab of the diamond into the prefab slot.

Painting with the prefab brush:

Within the Tilemap Palette’s window under the “Default” brush dropdown menu, we are now able to select several different styles of brush including the newly created Diamond brush.

To keep the objects in a organzied manner, we can create a new grid layer to house all the diamond objects before we start painting them. Then on the correct active grid, we can start painting the diamonds on the grid like any other tile.

--

--

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.