UI & Console API

Modified on Tue, 04 Dec 2018 at 01:06 PM

The console is shown pressing F1:



The console is useful to interact with the engine in many ways. Type /help to show a list of basic commands or /keys to show the current keys for moving the character controller and interact with the world.


The console API can be accessed through the static method VoxelPlayUI.instance.

The console is really split in 2 areas: the scrollable text area that shows all messages and the status bar.


To add a message to the status bar/console:


using VoxelPlay;
public class MyScript : MonoBehaviour {
     void Start() {
          VoxelPlayUI.instance.AddMessage(“Hello World!”);
     }
}



Console Events


The following events are exposed by the console:


Triggered when a new message is printed to the console
public event OnConsoleEvent OnConsoleNewMessage;


Triggered whhen a new command is entered by the user
public event OnConsoleEvent OnConsoleNewCommand;



Console Methods


Shows/hides the console
public void ToggleConsoleVisibility (bool state)
 
Adds a custom text to the console
public void AddConsoleText (string text)


Adds a custom message to the status bar and to the console
public void AddMessage (string text)


Hides the status bar
public void HideStatusText()



Inventory Methods


Shows/hides the inventory
public void ToggleInventoryVisibility (bool state)
 
Redraws contents of inventory 
public void RefreshInventoryContents ()


Shows currently selected item
public void ShowSelectedItem (InventoryItem inventoryItem)


Hides the selected item
public void HideSelectedItem()



Events


/// Triggered when a new message is added to the console

public event OnConsoleEvent OnConsoleNewMessage;


/// Triggered when a new command is entered by the user (you can use this event to implement custom console commands. Return false from the delegate function to capture the command entered by user).

public event OnConsoleEvent OnConsoleNewCommand;


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article