UI & Console API

advanced scripting

Voxel Play 3 · Scripting / API

Overview

The console is accessible by pressing F1. It enables interaction with the engine in various ways. Users can type /help to view basic commands or /keys to display current controls for character movement and world interaction.

The console API is accessed through VoxelPlayUI.instance. The console comprises two sections: a scrollable text area displaying all messages and a status bar.

Adding Messages to Console

using VoxelPlay;

public class MyScript : MonoBehaviour {
    void Start() {
        VoxelPlayUI.instance.AddMessage("Hello World!");
    }
}

Console Events

  • OnConsoleNewMessage - Triggered when a new message is printed to the console
  • OnConsoleNewCommand - Triggered when a new command is entered by the user

Console Methods

  • IsConsoleVisible - Returns true if the console is visible
  • ToggleConsoleVisibility(bool state) - Shows/hides the console
  • AddConsoleText(string text) - Adds custom text to the console
  • AddMessage(string text, float displayTime = 4f, bool flash = true, bool openConsole = false) - Adds custom message to status bar and console
  • HideStatusText() - Hides the status bar

Inventory Methods

  • IsInventoryVisible - Returns true if the inventory is visible
  • ToggleInventoryVisibility(bool state) - Shows/hides inventory
  • InventoryNextPage() - Advances to next inventory page
  • InventoryPreviousPage() - Shows previous inventory page
  • RefreshInventoryContents() - Redraws inventory contents
  • ShowSelectedItem(InventoryItem inventoryItem) - Shows currently selected item
  • HideSelectedItem() - Hides the selected item

Other Methods

  • ToggleInitializationPanel(bool visible, string text = "", float progress = 0) - Shows/hides loading panel
  • ToggleDebugWindow(bool visible) - Shows/hides debug window
Was this page helpful?