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.
TesseraInstantiateOutput lets you customize where the instances are written to, and also which prefab should be instantiated for each tile.
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 this applies to the child objects of the tiles.
To use it, create an object with a MeshFilter and MeshRenderer. It doesn't need a mesh configured, but you should set the material(s) you want to use. Then add TesseraMeshOutput as a component to the generator, and set the target to the created object.
Tessera will automatically detect matching materials between the tiles and target object, and merge the meshes into submeshes to take advantage of it.
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.