Controlling Output
Note
Output control is only available in Tessera Pro
By default, after doing generation, TesseraGenerator
will instantiate copies of all the tiles as child objects.
This is usually what you need, but it is possible to customize it further.
Creating instances
By default Tessera will instantiate each tile as a child of the generator. If you want to customize this, you can use a TesseraInstantiateOutput.
When using TesseraInstantiateOutput, instead of creating a copy of the tile itself, you can specify a different prefab to be instantiated instead.
Each mapping lists From
, which must be a tile in the Generators list of tiles, and To
, which is the prefab that should be instantiated whenever that tile is generated.
You can also set Instantiate Children Only
which works the same as the equivalent setting on the Tile components.
Writing to a Tilemap
Unity comes with a Tilemap component that lets you store sprites and components in a regular grid.
To enable this, select the game object with the TesseraGenerator
component, and add the TesseraTilemapOutput component. Then set the Tilemap
property to the tilemap component. Then instead of instantiating objects, it will find the appropriate for cell fo the tilemap, and fill that in instead.
Note
You must ensure that the grid spacing of the Tilemap and of the generator are aligned.
Tessera comes with a sample called "Platformer" that demonstrates writing to Tilemaps.
If you check the Use Sprites
property, then Tessera will attempt to detect game objects that contain a sprite, and write the sprite directly to the tilemap. This is considerably more efficient that inserting the entire game object into the tilemap, but you lose any other components.
Writing to a Mesh
You can use TesseraMeshOutput to write directly to a mesh. Your tiles objects must have a MeshFilter and MeshRenderer, unless you check Instantiate Children Only, in which case the children must have a MeshFilter and Mesh Renderer.
Materials
Because Tessera is merging multiple tiles, the resulting mesh will often need multiple materials. There are different options for how to handle this.
- Single - Ignore the materials set on the tiles, and just use the specified material instead
- Unique - Use every material found on any tile.
- UniqueByName - Use every material found on any tile, deduplicating materials if they share the same name.
Colliders etc
All non-mesh details of the tiles, such as colliders are lost. This might be improved in later versions
Chunking
By default, mesh output writes to a single MeshFilter on the generator itself. This can get awkward for large generations. By enabling chunking, the tiles will be split into small groups, and a separate MeshFilter/MeshRenderer created for each.
Handling the output in code
When invoking the Generate method, you can set onComplete or onComplete to completely replace the the default behaviour with your own code. There's an example in the API.