Unity Rule Tile: How to Set Random GameObject Output Instead of Sprite for a Tiling Rule?

Although it seems like a simple problem, it’s beyond my current skill level, so I wanted to reach out to the Unity experts in this community for help.

I’m working on a Rule Tile with a 3D mesh GameObject, and I want a specific Tiling Rule to output a random selection from multiple GameObjects instead of Sprites. I’ve set the output to ‘Random,’ but it only supports Sprites by default. I’m trying to create a custom Rule Tile that inherits from the default Rule Tile, but also allows GameObjects as output in addition to Sprites. However, I’m having trouble making it work. Any advice on implementing this would be greatly appreciated!

It’s unfortunately not quite that simple. The Rule Tile system was coded a long time ago before more flexible ways to write code and serialize data (such as with [SerializeReference]) was available. The output is handled by an enum making it impossible to extend without directly modifying the code.

The most straight-forward way to hack it in would be to make the package local and directly modify the code in such a way to allow this. To do this with a custom rule tile would pretty much involve doing all the code all over again with a few minor differences.

1 Like

You can spawn a gameobject with a component(X). The X component will spawn another gameobject randomly from a [serializefield] gameobject array on the same position

Dont forget to destroy the gameobject with the X component afterwards

In either way this is shooting yourself in the foot twice :gun: