Layout System : Introduction
TilePlus Toolkit’s Layout system was changed in Versions 4 and 5. It’s more memory efficient and sports better performance.
The older system required the use of a Template Tool to break up a set of layered Tilemaps into numerous TileFabs and their child TileBundles, one TileFab for each subdivision (AKA, Chunk) of the Tilemaps. It had two disadvantages:
- The TemplateTool can take a while to run, up to several minutes, which is annoying when iterating designs.
- The chunk size chosen when the TemplateTool runs can’t be changed later.
The new system does away with the TemplateTool. One just creates a TileFab by creating a GridSelection and TilePlus Toolkit tools. The created TileBundles subdivide themselves and cache these subdivisions at runtime with a chunk size of your choice that’s also provided at runtime. Hence, if certain rules are followed, any chunk size can be used.
These are the rules:
- The bounds captured in a TileFab and its child Bundles must be square.
- The size of the bounds must be divisible by 2.
- The selected chunk size must be evenly divisible into the bounds; for example:
- TileFab of 256x256. Square: check. Divisible by 2: check. A Chunk Size of 12 = error.
- TileFab of 200x200. Square: check, Divisible by 2: check. A Chunk Size of 16 = error.
This is tested and if you get it wrong there will be errors and warnings printed to the console. In general, sticking to powers of 2 works best.
So, what does the layout system do?
In its current form, it supports top-down games and loading of multiple “Tile Scenes” or TScenes within one Unity scene. There’s also a handy Tile-scene manager that lets you easily load TScenes without dealing with the underlying complexity.
The system can also support side scrolling as seen in the Side Scroll Layout Demo, however, this is a very basic demo.