SynchronizationContextStatusBar

Internal editor utility that injects a label into Unity's status bar displaying the name of the currently active SynchronizationContext. Useful for verifying that ParagonSynchronizationContext is correctly installed at runtime and in the editor.

Definition

Namespace: Paragon.Editor Assembly: Paragon.Editor.dll

[InitializeOnLoad]
internal static class SynchronizationContextStatusBar

Remarks

This class uses reflection to access Unity's internal AppStatusBar type and injects a custom OnGUI callback via OnGUIInjector. The label displays a shortened version of the active synchronization context's type name:

Active Context
Displayed Label

ParagonSynchronizationContext

Current Context: Paragon

UnitySynchronizationContext

Current Context: Unity

Default .NET SynchronizationContext

Current Context: dotNET

The status bar can be toggled on or off via the Enabled property, which is persisted as an editor preference through the [EditorPreference] attribute.

Properties

Enabled

Controls whether the synchronization context label is visible in the status bar. Persisted across editor sessions via editor preferences.

Behavior

Initialization

The static constructor runs on editor load ([InitializeOnLoad]):

  1. Resolves Unity's internal AppStatusBar type via reflection.

  2. Registers OnEditorUpdate as a delayed call to find the status bar instance.

  3. Subscribes to playModeStateChanged to trigger repaints on mode transitions.

OnGUI Injection

Once the AppStatusBar ScriptableObject is found, OnGUIInjector.Inject() hooks a custom OnGUI callback that renders the context label in the status bar area, right-aligned with an offset to avoid overlapping Unity's built-in status elements.

Context Name Resolution

The context name is cached and only re-evaluated when the SynchronizationContext.Current instance changes. The type name is simplified by stripping the "SynchronizationContext" suffix (e.g., ParagonSynchronizationContext"Paragon"). If the resulting name is empty (i.e., the type is exactly SynchronizationContext), it falls back to "dotNET".

See Also

Last updated