Skip to main content

PixelMapChunkDisplay

A class in Root.Township, Alta.Caves.Displays.

Debug cave chunk display that draws one Y slice of its layer as a greyscale texture on a flat quad.

Constructors​

MemberWhat it is
PixelMapChunkDisplay()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

6 private and internal fields
MemberWhat it is
private MeshFilter filterThe MeshFilter showing the quad.
private static Queue<Texture2D> poolShared pool of reusable textures.
private static Mesh quadShared quad mesh used by every instance.
private MeshRenderer quadRendererThe renderer whose material shows the texture.
private Texture2D textureThis chunk's texture.
private int yIndexWhich Y slice of the layer to draw.

Methods​

MemberWhat it is
override void Initialize()Builds the shared quad mesh if needed, assigns a pooled texture and scales the quad to the chunk size.
override IEnumerator Render() (iterator)Writes the layer values at yIndex into the texture as black to white pixels.
2 private and internal methods
MemberWhat it is
private Texture2D GetTexture()Takes a texture from the shared pool, filling the pool with 100 new chunk-sized textures when empty.
private void OnDestroy()Returns the texture to the pool.