_ _ _ _ _____ _____ _ | | | | | | | __ \ / ____| | | | |__| | | | | | | | | | ___ _ __ ___ ___ | | ___ | __ | | | | | | | | | / _ \| '_ \/ __|/ _ \| |/ _ \ | | | | |__| | |__| | | |___| (_) | | | \__ \ (_) | | __/ |_| |_|\____/|_____/ \_____\___/|_| |_|___/\___/|_|\___| garrettshields.me/hudconsole/
HUD Console is a polished, extendable console that can easily be added to your existing Unity projects.
Adding HUD Console to your project.
To add the console to your project import this into your Unity project, the console will self instantiate at runtime. The console can be opened by pressing Grave '`' (The key above tab).
Accessing the Console.
The console can be accessed by either typing out it's namespace for each use:
Or you can add it's namespace to the top of each file that will be accessing it.
HUD Console has the same log types as Unity.
Error, Assert, Warning, Log, Exception.
They can be used using the following commands:
Console.Log("Hello"); Console.LogWarning("Hello"); Console.LogError("Hello"); Console.LogAssert("Hello"); Console.LogException("Hello");
From code, you can also just use Console.Log and pass in the LogType as an argument.
For logs of LogType.Log you can also specify custom colors for text, and background.
Console.Log("Hello", Color.white, Color.black);
Commands can be added by using Console.AddCommand. It requires 3 arguments:
- A string that will be used as the key for accessing the command.
- The function you would like the command to execute.
- A string that will be displayed with the key when the "help" command is used.
Functions that are to be added as commands must match the following signature:
void MyFunction(string args)
In the Example folder look at Scripts/Welcome.cs or Scripts/Graph.cs line 54.
Built in commands.
The built in commands can be found in Console/Scripts/ConsoleCoreCommands.cs, and are added to the console in Console/Scripts/Console line 91.
As everyone's requirements of a console range quite considerably I have purposefully only included a handful of commands, however I plan on adding more in the future.
Creating new Color Sets.
New color sets can be created to customize the appearance of the console.
- Create a new ColorSet by right clicking in the Project tab and go to Create -> Console -> Obelisk ColorSet.
- Name the new ColorSet anything you like.
- Find Console/Obelisk/ObeliskConsole and change the ColorSet property to what ever ColorSet you like.
Creating your own implementation of the Console View.
The default implementation of HUD Console's view is called Obelisk, but you can also create your own.
These are the basic steps to creating your own view. (I may expand this later):
- Create a class that inherits from ConsoleViewAbstract.
- Override the virtual functions listed in ConsoleViewAbstract.
- Create a prefab with your new class as a component.
- Go to Console/Console and select your prefab in the ConsoleViewPrefab property.
- The rest is up to you! This is your view, make it how you like.