Skip to content

yanicksenn/unity-console

Repository files navigation

Unity Console

Unity3d package allowing the toggling of console output and debugging of UnityEvents.

Feedback is welcome.

Plug and Play

  1. Open "Package Manager"
  2. Choose "Add package from git URL..."
  3. Use the HTTPS URL of this repository: https://github.com/yanicksenn/unity-console.git#1.0.0
  4. Click "Add"

Usage

Console

A console can be created through the asset menu > Create > Console > ... .

Asset menu

Logging

You can inject a console throught the inspector into your script.

Is is possible to use lazy logging or normal logging, although it is recommended to always use lazy logging inside of a script.

Lazy logging Normal logging
LazyLog(() => ...) Log(...)
LazyWarning(() => ...) Warning(...)
LazyError(() => ...) Error(...)
public class MyBehaviour : MonoBehaviour
{
    public Console console;
    
    private Start()
    {
        console?.LazyLog(() => "Hello, World!");
    }
}

Normal logging is recommended through a unity event.

public class MyBehaviour : MonoBehaviour
{
    public UnityEvent unityEvent = new UnityEvent();
    
    private Awake()
    {
        unityEvent.Invoke();
    }
}

Unity event

After the untiy event was invoked the following output will appear in the editor console.

Output

Toggling

No messages will be printed to the console when it is set to inactive.

Toggle active

Active console

Toggle inactive

Inactive console

Lazy logging ensures that no messages are generated while normal logging always generates a message but will only print it when the console is active.

About

Unity3d package allowing the toggling of console output and debugging of UnityEvents.

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages