Skip to main content

ChunkDisplayTool

A class in Root.Township, ATT.FeatureTestGymnasium.

Debug tool for the feature test gymnasium that draws coloured quads over chunk bounds: none, all chunks or loaded ones only. Singleton behaviour.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private LocationChunk[] allSceneChunksBacking field for AllSceneChunks.
private readonly Dictionary<int, GameObject> cachedChunkDisplaysQuad object per chunk, keyed by chunk hash code.
private Renderer chunkDisplayPrefabQuad prefab to spawn per chunk.
private GymnasiumVisualChunkDisplayMode defaultModeMode set on enable.
private int displayOpacityAlpha (0 to 255) for the quad colours.
private readonly HashSet<int> loadedChunksHash codes of chunks that have fully loaded. Never removed on unload.
private static readonly Quaternion QuadRotationRotation that lays the quad flat.

Properties​

MemberWhat it is
GymnasiumVisualChunkDisplayMode CurrentMode { get; private set; }The current display mode. Set to the default on enable, but not applied until AdvanceMode.
2 private and internal properties
MemberWhat it is
private LocationChunk[] AllSceneChunks { get; }Every LocationChunk in the scene, found once and cached.
private GymnasiumVisualChunkDisplayMode NextMode { get; }The mode after the current one, wrapping round.

Methods​

MemberWhat it is
void AdvanceMode()Switches to the next display mode and applies it.
10 private and internal methods
MemberWhat it is
private void ApplyMode(GymnasiumVisualChunkDisplayMode mode)Shows or hides chunk quads for the given mode.
private GameObject CreateChunkQuad(Bounds bounds)Spawns a quad the size of the chunk bounds with a random bright colour.
private void DisplayAll()Shows a quad for every chunk in the scene.
private void DisplayChunkVisual(Chunk chunk)Shows the chunk's quad, creating it the first time.
private void DisplayLoadedOnly()Hides all quads, then shows those for chunks that have loaded.
private void DisplayNone()Hides every quad.
private void OnChunkLoaded(Chunk chunk)Records the chunk as loaded and shows it in loaded-only mode.
private void OnChunkUnLoaded(Chunk chunk)Hides the chunk's quad in loaded-only mode. It stays in loadedChunks.
private void OnDisable()Unhooks from every chunk's load events.
private void OnEnable()Sets the default mode and hooks every chunk's load and unload events.