Skip to main content

VirtualKey

A class in Root.Township, the global namespace.

One key on a VirtualKeyboard: shows its character (or shifted one) on a text renderer and sends its key code when pressed.

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private BoxCollider buttonColliderThe key's collider, scaled up for the space key.
private VirtualKeyInfo infoKey code and shifted key code for this key.
private Transform[] scalingTransformsTransforms scaled to spaceScale for the space key.
private Vector3 spaceScaleScale used for the space key.
private TextRenderer textText renderer showing the key's label.
private VirtualKeyboard virtualKeyboardThe keyboard this key belongs to.

Methods​

MemberWhat it is
void Press()Sends the key's code (or shift code while shift is held) to the keyboard.
void Setup(VirtualKeyInfo info, VirtualKeyboard virtualKeyboard)Stores the key info and keyboard, and updates the label when shift changes.
3 private and internal methods
MemberWhat it is
private void ApplyText(string newText)Sets the key's label if it changed.
private void OnDestroy()Unhooks from the keyboard's shift event.
private void UpdateImage(bool isShiftPressed)Sets the label from the key code, with symbols, names for modifiers and case for letters. The space key gets scaled instead.

Used in​

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