Show / Hide Table of Contents

Class TesseraGenerator

GameObjects with this behaviour contain utilities to generate tile based levels using Wave Function Collapse (WFC). Call Generate(TesseraGenerateOptions) or StartGenerate(TesseraGenerateOptions) to run. The generation takes the following steps:

  • Inspect the tiles in tiles and work out how they rotate and connect to each other.
  • Setup any initial constraints that fix parts of the generation (searchInitialConstraints and initialConstraints).
  • Fix the boundary of the generation if skyBox is set.
  • Generate a set of tile instances that fits the above tiles and constraints.
  • Optionally retries or backtrack.
  • Instantiates the tile instances.
Inheritance
Object
TesseraGenerator
Namespace: Tessera
Assembly: cs.temp.dll.dll
Syntax
public class TesseraGenerator : MonoBehaviour

Fields

backtrack

If set, backtracking will be used during generation. Backtracking can find solutions that would otherwise be failures, but can take a long time.

Declaration
public bool backtrack
Field Value
Type Description
Boolean

filterSurfaceSubmeshTiles

If true, and a surfaceMesh is set with multiple submeshes (materials), then use surfaceSubmeshTiles.

Declaration
public bool filterSurfaceSubmeshTiles
Field Value
Type Description
Boolean

initialConstraints

The initial constraints to be used, if searchInitialConstraints is false. This can be filled with objects returned from the GetInitialConstraint methods. You are recommended to use initialConstraints instead.

Declaration
[Obsolete("Use TesseraGeneratorOptions.initialConstraints instead")]
public List<TesseraInitialConstraint> initialConstraints
Field Value
Type Description
List<TesseraInitialConstraint>

retries

If backtracking is off, how many times to retry generation if a solution cannot be found.

Declaration
public int retries
Field Value
Type Description
Int32

searchInitialConstraints

If true, then active tiles in the scene will be taken as initial constraints. If false, then initialConstraints is used instead.

Declaration
public bool searchInitialConstraints
Field Value
Type Description
Boolean

skyBox

If set, this tile is used to define extra initial constraints for the boundary.

Declaration
public TesseraTile skyBox
Field Value
Type Description
TesseraTile

surfaceMesh

If set, then tiles are generated on the surface of this mesh instead of a regular grid.

Declaration
public Mesh surfaceMesh
Field Value
Type Description
Mesh

surfaceOffset

Height above the surface mesh that the bottom layer of tiles is generated at.

Declaration
public float surfaceOffset
Field Value
Type Description
Single

surfaceSmoothNormals

Controls how normals are treated for meshes deformed to fit the surfaceMesh.

Declaration
public bool surfaceSmoothNormals
Field Value
Type Description
Boolean

surfaceSubmeshTiles

A list of tiles to filter each submesh of surfaceMesh to. Ignored unless filterSurfaceSubmeshTiles is true.

Declaration
public List<TileList> surfaceSubmeshTiles
Field Value
Type Description
List<TileList>

tiles

The list of tiles eligable for generation.

Declaration
public List<TileEntry> tiles
Field Value
Type Description
List<TileEntry>

tileSize

The stride between each cell in the generation. "big" tiles may occupy a multiple of this tile size.

Declaration
public Vector3 tileSize
Field Value
Type Description
Vector3

Properties

bounds

The area of generation. Setting this will cause the size to be rounded to a multiple of tileSize

Declaration
public Bounds bounds { get; set; }
Property Value
Type Description
Bounds

center

The local position of the center of the area to generate.

Declaration
public Vector3 center { get; set; }
Property Value
Type Description
Vector3

palette

Inherited from the first tile in tiles.

Declaration
public TesseraPalette palette { get; }
Property Value
Type Description
TesseraPalette

size

The size of the generator area, counting in cells each of size tileSize.

Declaration
public Vector3Int size { get; set; }
Property Value
Type Description
Vector3Int

Methods

Clear()

Clear's previously generated content.

Declaration
public void Clear()

Generate(TesseraGenerateOptions)

Synchronously runs the generation process described in the class docs.

Declaration
public TesseraCompletion Generate(TesseraGenerateOptions options = null)
Parameters
Type Name Description
TesseraGenerateOptions options
Returns
Type Description
TesseraCompletion

GetInitialConstraintBuilder()

Declaration
public TesseraInitialConstraintBuilder GetInitialConstraintBuilder()
Returns
Type Description
TesseraInitialConstraintBuilder

GetMissizedTiles()

For validation purposes

Declaration
public IEnumerable<TesseraTile> GetMissizedTiles()
Returns
Type Description
IEnumerable<TesseraTile>

Instantiate(TesseraTileInstance, Transform)

Utility function that instantiates a tile instance in the scene. This is the default function used when you do not pass onCreate to the Generate method. It is essentially the same as Unity's normal Instantiate method with extra features:

  • respects instantiateChildrenOnly
  • applies mesh transformations (Pro only)
Declaration
public static GameObject[] Instantiate(TesseraTileInstance instance, Transform parent)
Parameters
Type Name Description
TesseraTileInstance instance

The instance being created.

Transform parent

The game object to parent the new game object to. This does not affect the world position of the instance

Returns
Type Description
GameObject[]

The game objects created.

Regenerate(TesseraGenerateOptions)

Runs Clear, then Generate

Declaration
public TesseraCompletion Regenerate(TesseraGenerateOptions options = null)
Parameters
Type Name Description
TesseraGenerateOptions options
Returns
Type Description
TesseraCompletion

StartGenerate(TesseraGenerateOptions)

Asynchronously runs the generation process described in the class docs, for use with StartCoroutine.

Declaration
public IEnumerator StartGenerate(TesseraGenerateOptions options = null)
Parameters
Type Name Description
TesseraGenerateOptions options
Returns
Type Description
IEnumerator
Remarks

The default instantiation is still synchronous, so this can still cause frame glitches unless you override onCreate.

Back to top Generated by DocFX