Skip to main content

RuntimeConsole

A class in Root.Township, the global namespace.

In-game VR console panel: shows log output and runs typed commands on the client or, with its lever, on the server. Client side.

Constructors​

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

Fields​

13 private and internal fields
MemberWhat it is
private Color debugColorText colour for debug logs.
private RuntimeConsole.CommandTarget defaultCommandTargetWhether commands run on the client or server when the panel opens.
private Color errorColorText colour for error logs.
private Color infoColorText colour for info logs.
private bool isRunningCommandOnServerTrue while the lever is set to the server.
private InputFieldWithKeyboard keyboardSetupInput field with its virtual keyboard.
private SelectionLever leverLever that picks client or server.
private TextRenderer leverTextLabel showing the lever's current target.
private RuntimeConsole.LogFilter logFilterLog levels to hide; none shows everything.
private readonly Queue<string> outputBufferQueue of formatted log lines shown in the output.
private TextRenderer outputFieldText renderer for the log output.
private Color traceColorText colour for trace logs.
private Color warningColorText colour for warning logs.

Properties​

MemberWhat it is
IUseVirtualKeyboard KeyboardUser { get; }The input field that uses the virtual keyboard.

Events​

1 private and internal event
MemberWhat it is
private event Action OnBufferChangedRaised when a log line is added.

Methods​

19 private and internal methods
MemberWhat it is
private void Awake()Hooks the input field's submit and the server and console command log streams.
private static string ColorToHex(Color c)Turns a colour into a #RRGGBB string.
private void CopyBufferToOutput()Writes the buffered log lines into the output text.
private bool FilterOutput(LogLevel level)True when a log level should be hidden. It casts the level number straight to a flag, so the filter flags don't match level names one to one.
private string FormatLogMessage(string message, LogLevel level)Wraps a message in a colour tag for its log level.
private string GetLogColorAsHexString(LogLevel level)Returns the hex colour for a log level.
private void OnDestroy()Unhooks the submit and log events.
private void OnDisable()Hides the keyboard and unhooks the lever and buffer events.
private void OnEnable()Fills the output, shows the keyboard and sets the lever to the default target.
private void OnInputSubmitted(InputField field)Runs the typed command on the server or client and clears the field.
private void OnLeverSelectionChanged(SelectionLever _, int previous, int current)Switches between client and server commands and updates the lever label.
private void OnLog(string message, LogLevel level)Adds a log line to the buffer, dropping old ones past the output's line limit.
private void RunCommandOnClient(string command)Runs a command locally through CommandService.
private void RunCommandOnServer(string command)Sends a command to the server through CommandSync.
private void SetupBuffer()Shows the current buffer and listens for new lines.
private void SetupCommandTarget()Hooks the lever and sets it to defaultCommandTarget.
private void SetupKeyboard()Shows the virtual keyboard.
private void TeardownKeyboard()Hides the virtual keyboard.
private static byte ToByte(float f)Turns a 0 to 1 colour value into a byte.

Used in​

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