-
-
Notifications
You must be signed in to change notification settings - Fork 0
Extra Resources
The following are tool classes included with InputLayers:
- SingletonScriptableObject: A useful tool to store references accessible from anywhere.
- PseudoSerializableDictionary: A dictionary-like structure that can be serialized.
- StackableList: A stack-like list class.
When using InputLayers, you are likely to notice the formatted logging that it uses. This is the result of custom versions of default Unity classes with built-in extended logging functionality:
Original Class | Custom Class |
---|---|
MonoBehavior🔗 | LowryBehavior |
ScriptableObject🔗 | LowryScriptable |
Editor🔗 | LowryEditor |
EditorWindow🔗 | LowryEditorWindow |
PropertyDrawer🔗 | LowryPropertyDrawer |
These custom classes offer a number of logging tools designed to perform well, and offer better visual clarity when reading logs in the Unity Editor, as well as when exported. Here is a list of the built-in features, and how they can be used/configured:
The core idea is to replace standard logging methods with custom variants that inject visual information to help identify the class they originate from, and display objects in a human-readable way using JSON.
Original Class | Custom Class |
---|---|
Debug.Log()🔗 | LogMsg() |
Debug.LogWarning()🔗 | LogWarning() |
Debug.LogError()🔗 | LogError() |
Note: Some variants, like
LowryEditor
may not include the full suite of logging tools as InputLayers does not require them in that context.
// Standard approach to logging
Debug.LogWarning("Beware!");
Debug.Log("Something happened", _contextObject);
// Custom logging approach
LogWarning("Beware!");
LogMsg(_objectToDisplayAsJson, "Something happened");
For optimization purposes, it is recommended to avoid passing formatted strings, and instead pass elements as arguments:
// DO NOT DO THIS
LogMsg($"A log about {_name}");
// Do this instead
LogMsg("A log about {0}", _name);
An extra feature of these classes is the ability to enable or disable logging for each individual class or class instance either through code, or directly within the Unity inspector.
This is accomplished using a pair of field:
private bool d_debug;
Exposes a toggle in the inspector that only allows an instance of this class to display custom log messages if it is set to
true
.
protected static bool d_debugOverride;
If overridden to
false
, this value will override d_debug and disable custom logging for all instances of this class.
When using the above methods, a colorful title can be injected before the log. This is designed to help quickly and easily distinguish the source of the log.
In order to use this functionality, your class inhabiting from a custom "Lowry" class will need to override the d_logHeader
value:
protected override string d_logHeader => "[The name of the class, or some other identifyer]";
For visual clarity, InputLayers always puts these titles betwee, brackets.
By default, different colors are used for various class types:
Class | Default Color |
---|---|
LowryBehavior |
headerOrange |
LowryScriptable |
headerPink |
LowryEditor |
headerGreen |
LowryEditorWindow |
headerGreen |
LowryPropertyDrawer |
headerGreen |
However, in the case of LowryBehavior
and LowryScriptable
classes, the color can be overridden like this:
protected override Log.Colors d_logHeaderColor => Log.Colors.headerGrass;
Here is the list of available colors; which can be modified by editing the Lowry.Utils.Logs
file:
- headerOrange
- headerPink
- headerGrass
- headerPurple
- headerGreen
- headerWine
👉🏻 Download InputLayers on the Unity Asset Store!