Skip to main content

ServerElement

A class in Root.Township, the global namespace.

One entry on the main menu's server list: shows a server's name, player count and playability colour, and can be selected.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private ServerSelectionDisplay displayThe server selection display this element belongs to, set by SetDisplay.
private ToggleEvent elementSelectedToggle event invoked with the selected state in SetSelected.
private bool isConnectingToServerInspector button: when ticked, joins the shown server through VrMainMenu.
private bool isInstancedMaterialsTrue once SetupForServer has made instanced materials for the playability renderers.
private TextRenderer numberOfPlayersTextText showing the server's online player count.
private Renderer[] playabilityRenderersRenderers tinted by the server's playability using the menu settings gradient.
private Renderer rendererToSelectRenderer whose material swaps between selected and normal.
private TextRenderer serverNameTextText showing the server name.

Properties​

MemberWhat it is
GameServerInfo ServerInfo { get; private set; }The server shown.

Methods​

MemberWhat it is
void Select()Selects this entry on its display, if it is interactable.
void SetDisplay(ServerSelectionDisplay display)Sets the list this entry belongs to and deselects it.
void SetSelected(bool isSelected)Shows the entry as selected or not.
void SetupForServer(GameServerInfo server)Fills the entry from a GameServerInfo.
protected override void OnValidate()Editor: the inspector's connect button joins the shown server.
2 private and internal methods
MemberWhat it is
private void OnDestroy()Destroys the instanced playability materials if any were made.
private void IBuildRendererPostBake.PostBake()Build bake hook: strips null entries from playabilityRenderers.

Used in​

Members of other types that take, return or hold a ServerElement: