GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - BarionLP/UnityConsole: A Unity Runtime Console using UI Toolkit

BranchesTags
Open more actions menu

Latest commit

 

History

44 Commits
44 Commits

Folders and files

NameName
Last commit message
Last commit date
Runtime
Runtime
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
LICENSE.meta
LICENSE.meta
 
 
README.md
README.md
 
 
README.md.meta
README.md.meta
 
 
Runtime.meta
Runtime.meta
 
 
package.json
package.json
 
 
package.json.meta
package.json.meta
 
 

Repository files navigation

UnityConsole

A Unity Runtime Console using UI Toolkit

Usage

  • requires Unity UI package (UI Toolkit)
  • new input system recommended
  • install Unity Console package https://github.com/BarionLP/UnityConsole.git
  • add the ConsolePrefab to your scene

Add Messages

ConsoleManager.AddMessage("message");
ConsoleManager.AddMessage("<color=yellow>message</color>"); // rich text support 
ConsoleManager.AddWarningMessage("warning");
ConsoleManager.AddErrorMessage("error");

Hide and Show

ConsoleManager.Hide()/ConsoleManager.Show()
The ConsoleToggle component handles hiding and showing the console
You can listen to ConsoleManager.OnShow and ConsoleManager.OnHide

Input Handlers

by default the console just prints input messages

// override the default handler
ConsoleManager.OverrideDefaultHandler(new ConsoleMessageHandler(input => {}));
// registering other handlers
char prefix = '/'; // inputs staring with this prefix are handed to this handler
ConsoleManager.RegisterHandler(prefix, new ConsoleMessageHandler(input => {}));

Custom Handlers

// implement IConsoleHandler
public sealed class CustomHandler : IConsoleHandler
{
    // whether the prefix should be removed before calling Handle
    public bool PassPrefix => false;
    
    public void Handle(ReadOnlySpan<char> input)
    {
        // whatever you want
    }

    // optional
    public string GetHint(ReadOnlySpan<char> input)
    {
        // displays a hint above the text input, can be empty
        // runs whenever the input changes, so be performance aware 
    }

    // optional
    public string GetAutoCompleted(ReadOnlySpan<char> input)
    {
        // called when tab is pressed
        // return the completed string or empty
    }
}

Recommendation

If you want to run commands from this console consider using https://github.com/BarionLP/CommandSystem with https://github.com/BarionLP/UnityConsoleCommandIntegration

About

A Unity Runtime Console using UI Toolkit

Topics

unity

Resources

Readme
Activity

Stars

17 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.