- Home /
Teach the rule tile how to arrange tiles
Hey there,
I'm currently experimenting with the unity-extras, especially with the tile map extensions (Animated Tile, Rule Tile, etc.)
At the moment I am dealing with the Rule Tiles. And threre is one problem which I cannot solve. As an illustration I have 7 tiles that together make a clean transition of a wall.
I would like to teach the rule tile how to arrange these tiles based on the height of the wall (in tiles)
1. with 3 or less tiles, use the first three or less tiles from the top
2. at 4 - 7 use the first four to seven from below
3. at 8+ use the whole column and for the rest always the first tile
or something easier:
1. at 1-7 use the first 1-7 from the top
2. at 8+ use the entire column and for the rest always the first tile
Does anyone of you know a way to implement that?
Looking forward for a reply
LG Kasko ;)
Answer by wouter_v · Jul 26, 2018 at 05:37 PM
You'd probably have to make your own ruletile, you should look into how they actually work and extend them, i'm pretty sure they're just editor scripts. They supply a couple of examples which can be found here https://github.com/Unity-Technologies/2d-extras/tree/master/Assets/Tilemap/Tiles .
Yes I know. So I have to edit the RuleTile Script. The problem is that I do not know how to read out the height of the wall, or more generally of the element (which I can indeed connect with others). Whenever I add another tile on the top or bottom, I have to check the entire wall. But how can I implement that?
I've never done it so i have no idea. You might want to look at the PrefabBrush at the GetObjectInCell method. This seems to get a gameobject of the tile depending on the position. That way you might be able to extrapolate how many are above and below it. If you find a solution i'd love to hear it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612171539im_/https://answers.unity.com/themes/thub/images/avi.jpg)