@Frankorz I searched a very long time for the answer to this and I finally came up with a solution.
The first thing you will want to do is download the 2D Extras folder from Unity’s GitHub found at:
Click on “Clone or download” and choose “Download Zip”
Once it has downloaded, unzip it and drag the contents into “Assets” in your Unity project.
In Unity, in your project folder, right click and choose Create < Prefab Brush and name it whatever you choose. If you don’t see it in the create menu, try putting the cursor at the very top of the list and see if it scrolls. The “2D Extras” adds so much to the menu that it is larger than the screen and you may have to scroll to find it.
Now you need to create a prefab which is going to act as your tile. A tile is essentially just an image and a collider, so create an empty gameobject in the hierarchy and add these components in the inspector: Sprite Renderer & Box Collider 2D. Change the sprite to whatever you want the tile to be. Now you can add a script to the prefab. I made a very simple script just for test purposes:
void OnMouseDown(){
Debug.Log(“Hello”);
}
However, once you know this is working you can make the script anything you want it to be. Now, drag the gameobject into the project folder to make it into a prefab.
Now select your Prefab Brush in your Tile Palette and drag your Prefab into the "Prefabs"in the inspector of the brush. This is an array and you can add multiple prefabs if you so choose; however, this will choose one of the prefabs at random, according to the “Perlin Scale” slider which you can change. You will most likely need a dedicated brush for each prefab.
To use the brush, select it from within the Tile Palette and use it as you would the default brush.
This is the solution that I was able to come up with. If anyone finds a better method, please fill us in, as this method does have its downsides, but it does work. The references I used to help come up with this are:
TILEMAPS in Unity - YouTube