TilePlus Toolkit for Unity3D

TilePlus Toolkit

For articles about TilePlus Toolkit please click on TilePlus Toolkit Articles, above.

What is TilePlus Toolkit?

TilePlus Toolkit (TPT) comprises a set of new Tile classes, a new Brush, and a support library. Using the Brush is optional, but it adds some features that are especially useful when working with these new tiles as well as normal Tiles.

And it's free!

What’s it for?

It’s a system using cloned tiles, or to put it another way, the Tile asset that’s placed at a grid position on a Tilemap clones itself, and that clone replaces the placed Tile asset.

What does “cloned tiles” mean? Normally, when you use a brush to place a tile on a Tilemap or when you programmatically add a tile to a Tilemap, the Tilemap copies the tile’s asset reference, the sprite, the color, the Transform matrix, and the TileFlags from the tile asset into the internals of the Tilemap component.

When the Scene is saved, these items from the internals of the Tilemap component are what’s stored in the Scene file – nothing else from the Tile itself is saved in the Scene file. This is well-known behavior at this point.

For pure “art” tiles, where only the visual representation matters, the implementation is very sensible. You wouldn’t want to store a multitude of copies of the same tile information for the same, repeated tile when all you’re doing is displaying static sprites or static animations.

If you want to add additional serialized fields to a Tile subclass, you can, but the additional data isn’t copied to the Scene file, it’s only in the asset. You’ll discover that the default Brush’s Selection Inspector won’t even show the added fields. If you were able to edit the fields, the source asset in your project folder would change, so every instance of the tile would be affected. Not very useful.

What this means in practice is that you must place Game Objects and/or Prefabs in the scene to create certain types of functionality. This is a hassle because “workflow”.

Once you place a TPT tile, a copy or clone of the tile asset is created and the reference in the Tilemap is changed to the clone. Since the Tilemap maintains the reference, the clone is saved with the scene.

The cloned TPT tile becomes independent of the project asset, so editing its fields doesn’t affect the project asset. The Tile+Brush lets you edit the fields using attributes that you place on fields that you want editable.

If the Tilemap gets deleted or a different tile is placed in the same location, the reference count for the clone goes to zero, and it’s no longer saved with the scene and eventually gets garbage collected like any other object whose lifetime has expired.