Backbone - Logger
 
Loading...
Searching...
No Matches
Backbone::LoggerConfigEditor Class Reference

Custom inspector for LoggerConfig. More...

Inheritance diagram for Backbone::LoggerConfigEditor:

Public Member Functions

override void OnInspectorGUI ()
 Renders the custom inspector UI and applies serialized changes once.
 

Private Member Functions

void OnEnable ()
 Unity callback to cache SerializedProperty references.
 
void DrawCategoriesGroupedByPrefix ()
 Draws categories grouped by the segment before the first '.' in their name.
 
void DrawCategoryRow (SerializedProperty element, int index)
 Draws a single category row.
 
void ImportCategoriesFrom (LoggerConfig src, bool overwriteExisting)
 Merge categories from another LoggerConfig without clearing current ones.
 

Static Private Member Functions

static bool IsSymbolDefined (string symbol)
 Checks whether a scripting define symbol is present for the current build target group.
 
static void AddSymbol (string symbol)
 Adds a scripting define symbol to the current build target group if missing.
 
static void RemoveSymbol (string symbol)
 Removes a scripting define symbol from the current build target group if present.
 

Private Attributes

SerializedProperty globalLevelProp
 Serialized reference to LoggerConfig.globalLevel.
 
SerializedProperty categoriesProp
 Serialized reference to LoggerConfig.categories.
 
SerializedProperty colorModeProp
 Serialized reference to LoggerConfig.colorMode.
 
SerializedProperty groupByPrefixProp
 Serialized reference to LoggerConfig.groupByPrefix.
 
string newCategoryName = ""
 Temporary buffer for the “add category” text field.
 
const string SYMBOL = "ENABLE_LOGGING"
 Scripting define used to include logger calls in builds.
 
LoggerConfig importSource = null
 Source asset used to import/merge categories (editor-only, not serialized).
 

Detailed Description

Custom inspector for LoggerConfig.

Provides:

  • Global log level and color mode controls.
  • Category list with per-item toggle, name, color, and delete.
  • Optional grouping by category prefix (e.g., "Menu.UI" -> group "Menu").
  • Delete-whole-group with confirmation.
  • Import/Merge categories from another LoggerConfig (Keep or Overwrite).
  • Toggle for the ENABLE_LOGGING scripting define.
    Note
    Applies serialized changes exactly once at the end of OnInspectorGUI to keep IMGUI stable, except when confirming destructive operations where an early Apply is required before ExitGUI.

Member Function Documentation

◆ AddSymbol()

static void Backbone::LoggerConfigEditor::AddSymbol ( string symbol)
staticprivate

Adds a scripting define symbol to the current build target group if missing.

Parameters
symbolThe define symbol to add.

◆ DrawCategoriesGroupedByPrefix()

void Backbone::LoggerConfigEditor::DrawCategoriesGroupedByPrefix ( )
private

Draws categories grouped by the segment before the first '.' in their name.

  • Builds a map of prefix -> indices in the categories array.
  • Shows a tri-state group toggle (mixed when some but not all are active).
  • Clicking the group toggle assigns the same active state to all children.
  • Provides a Delete Group button with confirmation, removing all children safely.
  • Renders each child row via DrawCategoryRow; no mid-frame Apply calls.
    Note
    No ApplyModifiedProperties() here; it is deferred to OnInspectorGUI, except when confirming deletion.

◆ DrawCategoryRow()

void Backbone::LoggerConfigEditor::DrawCategoryRow ( SerializedProperty element,
int index )
private

Draws a single category row.

Parameters
elementSerializedProperty pointing to the category struct/object.
indexIndex of the category in the categories array (used for deletion).

Row layout:

  • Toggle (bound to 'active' via PropertyField for IMGUI stability)
  • Editable name (TextField)
  • Color picker (PropertyField)
  • Delete button (removes array element and exits GUI)
    Note
    No ApplyModifiedProperties() is called here.

◆ ImportCategoriesFrom()

void Backbone::LoggerConfigEditor::ImportCategoriesFrom ( LoggerConfig src,
bool overwriteExisting )
private

Merge categories from another LoggerConfig without clearing current ones.

Parameters
srcSource LoggerConfig asset.
overwriteExistingIf true, overwrite 'active' and 'color' for same-name entries; otherwise keep current.

Reads the source via SerializedObject to avoid requiring public access on the ScriptableObject. New categories are appended; existing names are kept or overwritten based on the flag.

◆ IsSymbolDefined()

static bool Backbone::LoggerConfigEditor::IsSymbolDefined ( string symbol)
staticprivate

Checks whether a scripting define symbol is present for the current build target group.

Parameters
symbolThe define symbol to check (e.g., "ENABLE_LOGGING").
Returns
True if present, false otherwise.

◆ OnEnable()

void Backbone::LoggerConfigEditor::OnEnable ( )
private

Unity callback to cache SerializedProperty references.

Finds and stores references to:

  • globalLevel
  • categories
  • colorMode
  • groupByPrefix

◆ OnInspectorGUI()

override void Backbone::LoggerConfigEditor::OnInspectorGUI ( )

Renders the custom inspector UI and applies serialized changes once.

  • Draws ENABLE_LOGGING define toggle and forces domain reload on change.
  • Draws global level and color mode fields.
  • Draws grouping toggle and either a grouped or flat category list.
  • Handles add, delete, and restore-defaults actions.
  • Provides Import/Merge from another LoggerConfig (Keep or Overwrite).
    Note
    Uses UpdateIfRequiredOrScript()/ApplyModifiedProperties() once to keep IMGUI consistent.

◆ RemoveSymbol()

static void Backbone::LoggerConfigEditor::RemoveSymbol ( string symbol)
staticprivate

Removes a scripting define symbol from the current build target group if present.

Parameters
symbolThe define symbol to remove.

Also cleans up duplicate separators and trims trailing semicolons.

Member Data Documentation

◆ categoriesProp

SerializedProperty Backbone::LoggerConfigEditor::categoriesProp
private

Serialized reference to LoggerConfig.categories.

◆ colorModeProp

SerializedProperty Backbone::LoggerConfigEditor::colorModeProp
private

Serialized reference to LoggerConfig.colorMode.

◆ globalLevelProp

SerializedProperty Backbone::LoggerConfigEditor::globalLevelProp
private

Serialized reference to LoggerConfig.globalLevel.

◆ groupByPrefixProp

SerializedProperty Backbone::LoggerConfigEditor::groupByPrefixProp
private

Serialized reference to LoggerConfig.groupByPrefix.

◆ importSource

LoggerConfig Backbone::LoggerConfigEditor::importSource = null
private

Source asset used to import/merge categories (editor-only, not serialized).

◆ newCategoryName

string Backbone::LoggerConfigEditor::newCategoryName = ""
private

Temporary buffer for the “add category” text field.

◆ SYMBOL

const string Backbone::LoggerConfigEditor::SYMBOL = "ENABLE_LOGGING"
private

Scripting define used to include logger calls in builds.


The documentation for this class was generated from the following file: