Rotorz Tile System Icon
Rotorz Tile System for Unity
API Reference
Available on the Unity Asset Store
TOC

Chunk Class

A chunk is a sub-grid of tiles which forms part of an overall tile system. The size of a chunk is specified when creating a tile system though can be changed via the tile system inspector.
public sealed class Chunk : MonoBehaviour
public sealed class Chunk extends MonoBehaviour

Refer to Chunks section of user guide for further information.

Methods

CalculateMidPoint(Space)
Calculate mid point of chunk.
CountNonEmptyTiles()
Count the number of non-empty tiles.
FindTileIndexFromGameObject(Transform)
Find index of tile with associated game object.

Fields

tiles
Array of tile data.

Properties

Dirty
Gets or sets a value indicating whether this Chunk is dirty.
First
Gets index of first tile in chunk.
IsEmpty
Gets a value indicating whether chunk is void of tiles.
ProceduralDirty
Gets or sets a value indicating whether the procedural mesh associated with this Chunk needs to be updated.
ProceduralMesh
Gets the associated procedural mesh component.
TileSystem
Gets the tile system component.

Remarks

Here are some of the benefits of using chunks:

  • Lower memory overhead (tile data) when large areas of tile system are empty because empty chunks can be stripped.
  • Tile system builder can combine static tiles into a single mesh on a per chunk basis. The chunk size can be fine tuned to improve rendering performance. When needed the combiner chunk size can be specified separately (see combineMethod).
  • Procedural meshes that are generated to represent 2D tiles are formed on a per chunk basis.
  • Custom game-specific scripts can be written to optimize performance as needed. This might be used, for example, to disable all tiles within a specific chunk based on distance.

Both the chunk map and tile data can be stripped for lower memory overhead at runtime. However, in some games these data structures can be useful.

Inheritance Hierarchy

System.Object
  Object
    Component
      Behaviour
        MonoBehaviour
          Rotorz.Tile.Chunk

See Also

Reference