Avoid using Unity Debug for messages, warnings or errors, and create dedicated container for the required logs context.
- Create containers for dedicated logs context.
- Ability to manually control container lifetime.
- Default "All" container which displays logs from all containers in order of their creation.
- Display StackTrace of logs with ability to open IDE where log was made.
To create container, use method Create from ConsoleContainer:
// Without specifying container name.
IConsoleContainer console = ConsoleContainer.Create();
// With specifying container name.
IConsoleContainer console = ConsoleContainer.Create("Custom Container");
To create logs in the container, use methods below:
// Inside class instance, where "this." will be the name of the class which creates logs in the container.
console.CreateText(this, "Text message");
console.CreateWarning(this, "Warning message");
console.CreateError(this, "Error message");
// Inside static context, where "this." won't work.
console.CreateText(nameof(ClassName), "Text message");
console.CreateWarning(nameof(ClassName), "Warning message");
console.CreateError(nameof(ClassName), "Error message");
To dispose container after it is no longer needed (useful for editor extensions or when reloading domain is disabled when entering play mode):
console.Dispose();
To install this package, simply open Unity Package Manager,
click on the + icon and select "Add package from git URL...",
then paste the following URL: https://github.com/romanlee17/com.romanlee17.consolecontainer.git
.
- Unity 2021.3 or later
- UI Toolkit to display editor window