This repository provides a custom script to address specific issues with TilingRuleOutput.Transform options in Unity's 3D Tilemap. If you encountered problems with certain transformation rules not working as expected, this fix is for you.
When using Unity's 3D Tilemap, the following transformation rules often do not behave as intended:
-
RotatedMirror: Inconsistent rendering when combining rotation and mirroring.

-
MirrorXY: Overlaps or misalignment when mirroring along both X and Y axes.

Below are additional examples illustrating the general problem and how this script addresses it:
Example settings for the RuleTile that may exhibit issues:

A sample of a tilemap with misaligned or incorrect tile transformations:

The same tilemap after applying the custom script:

- Download the script file: CustomRuleTile.cs.
- Add the script to your Unity project by placing it in your
Assets/Scriptsfolder (or any preferred folder). - Replace your existing RuleTile with the custom
CustomRuleTilein the Unity Editor. - Use the custom RuleTile in your tilemap to resolve transformation issues.
Note
The provided script extends Unity's RuleTile class and overrides its transformation logic to fix the mentioned issues.
This custom script overrides Unity's default RuleTile behavior to correctly handle all transformations, ensuring accurate rendering for tiles with rotation, mirroring, and combination transformations.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
[CreateAssetMenu]
public class CustomRuleTile : RuleTile {
public override bool RuleMatches(TilingRule rule, Vector3Int position, ITilemap tilemap, ref Matrix4x4 transform)
{
// Custom logic for handling transformations like Rotated, MirrorXY, etc.
// Full code provided in the repository
...
}
}
