Skip to main content

CubeMapUpdater

A class in Root.Township, the global namespace.

Main menu visual: gives a server's preview a cubemap picked from ServerCubeMaps for its scene, so each server keeps the same look. Does nothing on a headless server.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private static readonly int _CubeMapShader property ID for _CubeMap.
private ServerCubeMaps cubeMapsThe ServerCubeMaps asset listing cubemaps per scene.
private Material materialPer-instance copy of the target renderer's material.
private Dictionary<int, int> serverCubemapIDCache of the cubemap index chosen for each server ID.
private Renderer targetRendererRenderer whose material gets the cubemap.

Methods​

MemberWhat it is
void SetupServer(ServerElement newElement)Applies the cubemap for the given server list entry, caching its chosen index per server ID.
4 private and internal methods
MemberWhat it is
private void ApplyCubemap(Cubemap cubemap)Sets the loaded cubemap on the copied material's _CubeMap property.
private void Awake()Copies the target renderer's material so changes don't touch the shared one; on headless it just clears cubeMaps.
private int GetMapID(int serverIdentifier, int sceneIndex)Picks a cubemap index for the scene, seeded by the server ID so it's the same every time.
private void OnDestroy()Clears the texture and frees the copied material and the loaded cubemaps.