Skip to content

Console Manager Updates


Changes to the KeyboardManager and ConsoleManager are pretty huge. I moved them both inside the namespace BurtSharp.Util like they were supposed to be (SystemLogger is the only exception since it's so ubiquitous.)

Aside from a few name changes, the KeyboardManager hasn't really been changed, just augmented. I added the KeyPressCallback class, which uses a bunch of factory methods as constructors, to make it easier for the ConsoleManager to use the AddKeyPressCallback method. The variables named KeyPressDelegate1...KeyPressDelegate4 were not very descriptive, so I gave them names to tell what type of argument they accept, e.g. KeyPressDelegateStr.

The ConsoleManager has been completely overhauled, so you might as well look at it as a new file instead of looking at the diff. It now uses the singleton pattern like the SystemLogger. It breaks up the console into three sections: usage instructions, variable display, and log display. The usage instructions get created automatically from the different overloads of AddKeyPressCallback(), and those instructions always remain at the top of the window. The middle section takes up as much space as is needed for printing variables that will be updated every control loop. The remaining space at the bottom of the window shows the SystemLogger messages as well as messages written through the new method ConsoleManager.WriteLine(). My intent is for any program that uses the ConsoleManager to call ConsoleManager.WriteLine() in place of the standard Console.WriteLine() provided by the System library. Finally, using the up/down arrow keys or the PageUp PageDown keys you can scroll through the log display on the window.

The SystemLogger I mostly just rearranged and added comments. Most importantly, I removed the use of the UnityEngine's logging function and replaced it with a delegate that will be set in BurtSharpUnity. That way BurtSharp doesn't need the UnityEngine as a dependency. Since almost every project uses the SystemLogger, they did have UnityEngine as a reference. That's why it has been removed from the csproj files of most projects and the BurtSharp library as a whole.

Added a version of the CircularBuffer for storing strings, which is what manages the logger display on the console. While updating CircularBuffer I made some name changes (GetLast is now GetOldest) and added a few features to help support the console manager.

What to focus on

  • Program designed to test the new ConsoleManager in Sandbox is called ConsoleTest. It allows you to toggle whether or not there is a log display, AND whether or not the messages from the SystemLogger are being grabbed and rerouted to the window.
  • Programs that use the new ConsoleManager and should be tested: Example04-DisplayBasicInfo, DisturbanceObserverTest, MovementAnalysisTest, RobotAccelerationEstimatorTest
  • Test with burt/software/burt-sharp-unity!139 in a game to ensure that system logger output still goes to Unity Debug log when playing in the Unity editor


What issues does this fix?

  • Fixes #253
Edited by Craig McDonald

Merge request reports