Search Results for

    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 (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
    Object
    Component
    Behaviour
    MonoBehaviour
    TesseraGenerator
    Inherited Members
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: Tessera
    Assembly: Tessera.dll
    Syntax
    [AddComponentMenu("Tessera/Tessera Generator")]
    public class TesseraGenerator : MonoBehaviour

    Fields

    algorithm

    Controls the algorithm used internally for Wave Function Collapse.

    Declaration
    [Tooltip("Controls the algorithm used internally for Wave Function Collapse.")]
    public TesseraWfcAlgorithm algorithm
    Field Value
    Type Description
    TesseraWfcAlgorithm

    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
    [Tooltip("If set, backtracking will be used during generation.\nBacktracking can find solutions that would otherwise be failures, but can take a long time.")]
    public bool backtrack
    Field Value
    Type Description
    bool

    contradictionTile

    Game object to show in cells that cannot be solved.

    Declaration
    public GameObject contradictionTile
    Field Value
    Type Description
    GameObject

    failureMode

    Controls what is output when the generation fails.

    Declaration
    public FailureMode failureMode
    Field Value
    Type Description
    FailureMode

    filterSurfaceSubmeshTiles

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

    Declaration
    [Tooltip("If true, filters which tiles appear on each material (submesh) of the surface mesh.")]
    public bool filterSurfaceSubmeshTiles
    Field Value
    Type Description
    bool

    meshEdgesTolerance

    Controls the tolerance (snap size) of comparing vertices for MeshEdges

    Declaration
    public float meshEdgesTolerance
    Field Value
    Type Description
    float

    modelType

    Sets which sort of model the generator uses. The model dictates how nearby tiles relate to each other.

    Declaration
    public ModelType modelType
    Field Value
    Type Description
    ModelType

    overlapSize

    The size of the overlap parameter for the overlapping model. Overlapping

    Declaration
    public Vector3Int overlapSize
    Field Value
    Type Description
    Vector3Int

    recordUndo

    Records undo/redo when run by pressing the Generate button in the Inspector.

    Declaration
    [Tooltip("Records undo/redo when run in the editor.")]
    public bool recordUndo
    Field Value
    Type Description
    bool

    retries

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

    Declaration
    [Tooltip("How many times to retry generation if a solution cannot be found.")]
    public int retries
    Field Value
    Type Description
    int

    samples

    For overlapping models, a list of objects to use as input samples. Each one will have its children inspected and read out. Overlapping

    Declaration
    public List<GameObject> samples
    Field Value
    Type Description
    List<GameObject>

    scaleUncertainyTile

    If true, the uncertainty tiles shrink as the solver gets more certain.

    Declaration
    public bool scaleUncertainyTile
    Field Value
    Type Description
    bool

    searchInitialConstraints

    If true, then active tiles in the scene will be taken as initial constraints. If false, then no initial constraints are used. Using initialConstraints overrides either outcome.

    Declaration
    public bool searchInitialConstraints
    Field Value
    Type Description
    bool

    seed

    Fixes the seed for random number generator. If the value is zero, the seed is taken from Unity.Random

    Declaration
    [Tooltip("Fixes the seed for random number generator.\n If the value is zero, the seed is taken from Unity.Random.")]
    public int seed
    Field Value
    Type Description
    int

    skyBox

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

    Declaration
    [Tooltip("If set, this tile is used to define extra initial constraints for the boundary.")]
    public TesseraTileBase skyBox
    Field Value
    Type Description
    TesseraTileBase

    stepLimit

    How many steps to take before retrying from the start.

    Declaration
    [Tooltip("How many steps to take before retrying from the start.")]
    public int stepLimit
    Field Value
    Type Description
    int

    surfaceMesh

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

    Declaration
    [Tooltip("If set, then tiles are generated on the surface of this mesh instead of a regular grid.")]
    public Mesh surfaceMesh
    Field Value
    Type Description
    Mesh

    surfaceOffset

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

    Declaration
    [Tooltip("Height above the surface mesh that the bottom layer of tiles is generated at.")]
    public float surfaceOffset
    Field Value
    Type Description
    float

    surfaceSmoothNormals

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

    Declaration
    [Tooltip("Controls how normals are treated for meshes deformed to fit the surfaceMesh.")]
    public bool surfaceSmoothNormals
    Field Value
    Type Description
    bool

    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 eligible for generation.

    Declaration
    [Tooltip("The list of tiles eligible for generation.")]
    public List<TileEntry> tiles
    Field Value
    Type Description
    List<TileEntry>

    uncertaintyTile

    Game object to show in cells that have yet to be fully solved.

    Declaration
    public GameObject uncertaintyTile
    Field Value
    Type Description
    GameObject

    Properties

    CellGrid

    Indicates the cell type of the tiles set up.

    Declaration
    public IGrid CellGrid { get; }
    Property Value
    Type Description
    IGrid

    CellType

    Indicates the cell type of the tiles set up.

    Declaration
    public ICellType CellType { get; }
    Property Value
    Type Description
    ICellType

    bounds

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

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

    cellSize

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

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

    center

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

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

    origin

    Declaration
    public Vector3 origin { 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 cellSize.

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

    Methods

    Clear()

    Clears previously generated content.

    Declaration
    public void Clear()

    CloneSample(int, IEngineInterface)

    Dumps out the internal view of the sample. Can be used for diagnosing issues with reading samples.

    Declaration
    public void CloneSample(int index = 0, IEngineInterface engineInterface = null)
    Parameters
    Type Name Description
    int index
    IEngineInterface engineInterface

    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

    GetCellTypes()

    For validation purposes

    Declaration
    public IList<ICellType> GetCellTypes()
    Returns
    Type Description
    IList<ICellType>

    GetGrid()

    Describes the geometry and layout of the cells. See separate Sylves documentations for more details. https://www.boristhebrave.com/docs/sylves/1 Note: If you are using a Mesh Surface based grid, then GetGrid() can be quite slow, and you are recommended to cache the result of it.

    Declaration
    public IGrid GetGrid()
    Returns
    Type Description
    IGrid

    GetInitialConstraintBuilder()

    Declaration
    public TesseraInitialConstraintBuilder GetInitialConstraintBuilder()
    Returns
    Type Description
    TesseraInitialConstraintBuilder

    GetTileOutput(bool)

    Declaration
    public ITesseraTileOutput GetTileOutput(bool forceIncremental = false)
    Parameters
    Type Name Description
    bool forceIncremental
    Returns
    Type Description
    ITesseraTileOutput

    Instantiate(TesseraTileInstance, Transform, IEngineInterface)

    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, IEngineInterface engine = null)
    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

    IEngineInterface engine
    Returns
    Type Description
    GameObject[]

    The game objects created.

    Instantiate(TesseraTileInstance, Transform, GameObject, bool, IEngineInterface)

    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, GameObject gameObject, bool instantiateChildrenOnly, IEngineInterface engine = null)
    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

    GameObject gameObject

    The game object to actually instantiate. Usually this is instance.Tile.gameObject

    bool instantiateChildrenOnly

    Should gameObject be created, or just it's children.

    IEngineInterface engine
    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 EnumeratorWithResult<TesseraCompletion> StartGenerate(TesseraGenerateOptions options = null)
    Parameters
    Type Name Description
    TesseraGenerateOptions options
    Returns
    Type Description
    EnumeratorWithResult<TesseraCompletion>
    Remarks

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

    In this article
    Back to top Generated by DocFX