Skip to main content

Logging messages

Introduction

Console messages show what's wrong with your game without having to spam Unity with Debug.Log messages.

Logging

The simplest way of logging messages is by using qDebug, but can also be achieved directly via the Game Console Controller

using qASIC;
using qASIC.Console;
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
public void LogExample()
{
//Logging with the controller
GameConsoleController.Log("This is an example using the controller", "example color");

//Logging with qDebug
qDebug.Log("This is a normal message", "color is optional");
qDebug.Log("You can also specify a normal color", Color.green);
qDebug.LogWarning("This is a warning message");
qDebug.LogError("This is an error message");
}
}

Logging in commands

Console commands have their own special way of logging messages that is faster than any other method.

tip

You can create commands using the provided script template under Create/qASIC/Console Command. If it doesn't show up, restart the editor.

public class ExampleCommand : GameConsoleCommand
{
public override string CommandName { get; } = "example command";
public override string Description { get; } = "example command's description";

public override void Run(List<string> args)
{
if (!CheckForArgumentCountMin(args, 1)) return;
Log("This is an example", "example color");

//Special
LogError("This is an error");
ParseException("[some value here]", "bool"); //Result: Couldn't parse [some value here] to bool!
NoOptionException("[unknown option]"); //Result: Option [unknown option] does not exist!
}
}