Getting Started
All code is kept under the QFSW.QC
namespace
In order to get started as quickly as possible, simply follow the following steps:
- Ensure the Text Mesh Pro package is installed; this is done by default for new projects
- Add an Event System to your scene if you do not already have one
GameObject > UI > EventSystem
- Navigate to
Assets/Plugins/QFSW/Quantum Console/Source/Prefabs
and add theQuantum Console
prefab to your scene.
After this, you are ready to try out Quantum Console!
Tip
If you are using any SRPs in your project (LWRP, URP, HDRP) then please use the Quantum Console (SRP)
prefab instead. The default theme uses a glassy shader that is incompatible with SRPs; the Quantum Console (SRP)
prefab variant uses Default Theme (SRP)
instead which has been modified to use a transparent material that is compatible with all SRPs.
This prefab includes a QuantumConsole component that provides I/O to the core, autocomplete, formatting and much more. You are free however to use your own prefab with the QuantumConsole script or to make your own script entirely, as all the core functionality resides in the QuantumConsoleProcessor.
- To get started, use the
help
command. This will give you a brief intro into using the console - For more help about any specific command, use
man commandName
to see its user manual - For a list of all commands loaded by the processor, use
all-commands
Adding Commands
When integrating Quantum Console into your project you will likely want to add your own commands to the console.
To do this, you will need to use the [Command]
attribute.
By adding this to your function, property or field you can turn it into a command that will be loaded by the Quantum Console Processor.
Example
using QFSW.QC;
...
[Command]
public static int Add(int a, int b)
{
return a + b;
}
Which can be invoked by entering to the console
Add 10 20
For more, see the documentation on Commands
Autocomplete
Quantum Console can provide autocomplete suggestions whilst you type in a command. These suggestions can be cycled with tab and shift + tab (configurable via the QuantumKeyConfig) or can be clicked directly. Since the autocomplete is contextual, arguments like enums or macros can also be suggested while typing a command.
The man
Command
The man command will generate a user manual for the specified command.
By itself, it will be able to display all the available signatures of the command, and the type of each parameter used.
To add a description to the command, please include it in the [Command]
or [CommandDescription]
.
To give a parameter a description, please use [CommandParameterDescription]
See Included Commands for a list of included commands
Argument Parsing
By default, arguments are separated by whitespace.
This means that spawn player 10
would be interpreted as command called spawn
, that takes 2 arguments, player
and 10
.
Strings
This works fine for most use cases, however issues can happen when strings are involved.
If you want to pass a single argument with a space in it (for example, a string) you must enclose it with " "
.
Therefore, spawn "player 10"
would instead be parsed as a command called spawn
with 1 argument, player 10
.
If you want to have a string that contains the "
character in it, then you must escape the "
character by writing \"
instead;
this will prevent the parser from using it for argument splitting and will instead recognise it as a plain "
.
Arrays and Collections
Arrays, lists, and other supported collections can be inputted into the console by enclosing the elements within []
sort<int> [3, 2, 1]
The following example would use the generic command sort<T>
to sort an array of integers, thus would return [1, 2, 3]
Nested arrays may be used in a similar fashion, so [[Quantum, Console], [Array, Test]]
would be a valid input for a command expecting string[][]
, List<List<string>>
, List<string[]>
etc.