[OUT NOW] - Free Tool - Custom brush to paint random tiles with weighted probability - 2D Extras

I have written a custom brush script that will allow you to paint random tiles based on a probability. It works with Unity Tilemaps and the 2D Extras package. This code should be compatible with Unity 2017, 2018, 2019.4 and 2020.3. I think later versions of Unity use a new package obtained through the package editor, but I have not tried that yet - this will be helpful to anyone on these older versions of Unity in particular.

The script is here: How to paint random tiles with weighted probability – Unity Tilemap | 2D Extras – Stuart's Pixel Games

Basically, I wrote over the “Prefab Random Brush” because I didn’t find it very useful, and instead made a new brush that will paint random tiles, based on a probability assigned to each tile. You can use any kind of tile in any combination with each other other, rule and animates tiles, normal tiles, etc.

I also added functionality so that it would work with the fill tool.

Of course you could modify it to paint prefabs if you wanted, but I found using Rule Tiles to paint prefabs more useful and more compatible with the tile palette tools like the eraser. So then you could put prefabs inside Rule Tiles and still use this custom brush script.

Here’s quick previews:



Separately, if you’re just interested in how the random probabilities work, I have a stand-alone code sample of that here: Get Random Object with Probability – C# Script – Stuart's Pixel Games