Window Framework v1.2.4
Window Framework for Unity UI Toolkit
Loading...
Searching...
No Matches
GWG.WindowFramework.WindowFrameController Class Reference

The WindowFrameController is the central management component for the Window Framework system. It serves as a singleton that manages window frames, themes, tooltips, context menus, and persistent data. More...

Inheritance diagram for GWG.WindowFramework.WindowFrameController:

Public Member Functions

void AddOrUpdateWindowData (string dataKey, WindowFrameData windowData)
 Updates or adds window configuration data for persistence.
List< StyleSheet > BuildSheetList ()
 Builds a complete list of stylesheets for the current theme configuration.
void ClearPreferences (bool forceAll=false)
 Clears all framework preferences and window memory, resetting everything to defaults.
WindowFrameData GetWindowData (string dataKey)
 Retrieves window configuration data by its unique identifier.
void OpenSettingsWindow ()
 Opens the built-in settings window for configuring the window framework.
void ReopenWindows (float delay=0.1f)
 Restores previously opened windows from saved data after a specified delay.
void ReopenWindowsInternal ()
 Performs the actual window restoration from saved data.
void ResetSettings ()
 Resets all framework settings to their default values while preserving window memory data.
void SetActiveWindow (WindowFrame newTarget)
 Sets the specified window as the active window and deactivates all others.

Static Public Member Functions

static void AddElement (VisualElement newElement)
 Adds a visual element to the window framework's root element with special handling for WindowFrame instances.
static void ApplyTooltips ()
 Applies tooltip functionality to all UI elements based on current theme settings.
static void ApplyTooltips (VisualElement root)
 Applies tooltip manipulators to UI elements within the specified root element.

Public Attributes

VisualElement RootElement
 The root VisualElement that serves as the primary container for all UI elements.
WindowFrameThemeData themeData
 The theme data configuration for the window framework.
Dictionary< string, WindowFrameDataWindowFrameSettingsData = new Dictionary<string, WindowFrameData>()
 Dictionary storing configuration data for each window frame.

Properties

int ActiveThemeIndex [get]
 Gets the index of the currently active theme.
List< WindowFrameActiveWindowFrames [get]
 Gets a list of all currently active window frames in the framework.
int ContextMenuDelay [get, set]
 [DEPRECATED] Gets or sets the delay before a context menu is displayed.
float ContextMenuFadeDelay [get, set]
 Gets or sets the delay before context menus begin fading out.
float ContextMenuFadeTime [get, set]
 Gets or sets the duration of context menu fade-out animations.
StyleSheet CurrentStylesheet [get]
 Gets the primary stylesheet for the current theme.
List< StyleSheet > CurrentThemeStylesheets [get]
 Gets the current list of stylesheets based on active theme settings.
StyleSheet DefaultStylesheet [get, set]
 Gets or sets the default stylesheet used when themes are not enabled or set.
VisualElement GhostIcon [get, set]
GlobalsLoadOrder GlobalsLoadOrder [get, set]
 Gets or sets the loading order for global stylesheet relative to theme stylesheets.
StyleSheet GlobalStylesheet [get, set]
 Gets or sets the global stylesheet applied across all themes.
static WindowFrameController Instance [get, private set]
 Gets the singleton instance of the WindowFrameController.
bool MemoryEnabled [get, set]
 Gets or sets whether the framework should persist window states and settings.
int TooltipDelay [get, set]
 [DEPRECATED] Gets or sets the delay before a tooltip is shown or hidden.
float TooltipFadeDelay [get, set]
 Gets or sets the delay before tooltips begin fading out.
float TooltipFadeTime [get, set]
 Gets or sets the duration of tooltip fade animations.
TooltipFadeType TooltipFadeType [get, set]
 Gets or sets the type of fade animation for tooltips.
bool TooltipsActive [get, set]
 Gets or sets whether tooltips are active and functional.
float TooltipShowDelay [get, set]
 Gets or sets the delay before showing tooltips when hovering over elements.
static VisualElement UIRoot [get]
 Gets the root VisualElement for the window framework's UI hierarchy.
static WindowFrameTooltip WindowFrameTooltip [get, set]
 Gets or sets the static tooltip system instance.

Events

static Action< List< StyleSheet >, List< StyleSheet > > OnThemeChanged
 Event triggered when the application theme changes.

Private Member Functions

void AddGhostIcon ()
 [EXPERIMENTAL] Creates and configures the ghost icon for drag operations.
void ApplyThemeToPanel (IPanel panel, List< StyleSheet > sheets)
 Applies a list of stylesheets to a specific UI panel.
void Awake ()
 Initializes the WindowFrameController instance during Unity's Awake phase.
WindowFrame FindActiveWindowFrame ()
 Finds and returns the first active window frame.
WindowFrame FindFormostWindowFrame ()
 Finds and returns the foremost (top-level) window frame in the UI hierarchy.
void HandleThemeChanged (int newThemeIndex, StyleSheet newStylesheet)
 Handles theme change events and applies new stylesheets based on theme configuration.
void HandleWindowFrameAdded (WindowFrame window)
 Handles the event when a new WindowFrame is added to the framework.
void HandleWindowFrameRemoved (WindowFrame window)
 Handles the event when a WindowFrame is removed from the framework.
void LoadWindowFrameworkData ()
 Loads window framework configuration data from persistent storage.
void OnDestroy ()
 Handles cleanup and data persistence when the component is destroyed.
void OnDisable ()
 Unsubscribes from events when the component is disabled.
void OnEnable ()
 Subscribes to events and performs initialization when the component is enabled.
System.Collections.IEnumerator ReopenWindowsDelayed (float delay=0.1f)
 Internal coroutine that handles delayed window restoration.
void SaveWindowFrameworkData ()
 Saves current window framework configuration data to persistent storage.
void SetActiveWindowDelayed (WindowFrame newTarget, int delay=5)
 Sets the active window after a specified delay.
void SetDefaultValues ()
 Sets all configurable values to their default constants.
void Update ()
 Updates the controller state each frame during Unity's Update phase.

Private Attributes

List< StyleSheet > _appliedStylesheets = new List<StyleSheet>()
 Internal list tracking currently applied stylesheets for theme management.
InputAction _clickAction
 Input action for handling click events within the window framework.
VisualElement _ghostIcon
 [EXPERIMENTAL] The ghost icon element used for drag-and-drop operations.
float contextMenuFadeDelay = ContextMenuFadeDelayDefault
float contextMenuFadeTime = ContextMenuFadeTimeDefault
string dataFileName = "WindowFrameData.json"
 The filename for storing window framework data in the persistent data folder.
StyleSheet defaultStyleSheet
GlobalsLoadOrder globalsLoadOrder
StyleSheet globalStyleSheet
bool memoryEnabled = true
float tooltipFadeDelay = TooltipFadeDelayDefault
float tooltipFadeTime = TooltipFadeTimeDefault
TooltipFadeType tooltipFadeType = TooltipFadeType.FadeOut
bool tooltipsEnabled = true
float tooltipShowDelay = TooltipShowDelayDefault
UIDocument uiDocument
 The primary UIDocument component attached to this GameObject.
List< UIDocument > uiDocuments = new List<UIDocument>()
 A collection of additional UIDocument components managed by this controller.

Static Private Attributes

static WindowFrameTooltip _windowFrameTooltip
const float ContextMenuFadeDelayDefault = 0.75f
 Default delay before context menu fades (in seconds).
const float ContextMenuFadeTimeDefault = 0.5f
 Default context menu fade animation duration (in seconds).
const bool MemoryEnabledDefault = true
 Default state for memory/persistence system.
const float TooltipFadeDelayDefault = 0.75f
 Default delay before fading tooltips (in seconds).
const float TooltipFadeTimeDefault = 0.5f
 Default tooltip fade animation duration (in seconds).
const TooltipFadeType TooltipFadeTypeDefault = TooltipFadeType.FadeInAndOut
 Default tooltip fade behavior.
const bool TooltipsEnabledDefault = true
 Default state for tooltip system.
const float TooltipShowDelayDefault = 2
 Default delay before showing tooltips (in seconds).

Detailed Description

This component should be attached to a GameObject with a UIDocument component. It automatically handles initialization, event subscriptions, and cleanup operations.

Key Features:

  • Singleton pattern for global access
  • Theme management and switching
  • Window state persistence
  • Tooltip system management
  • Context menu configuration
  • Input handling for UI interactions

The controller persists across scene loads using DontDestroyOnLoad.

// Access the singleton instance
// Add a new window to the framework
var myWindow = new MyCustomWindow();
// Apply tooltips to a newly created UI element
The WindowFrameController is the central management component for the Window Framework system....
Definition WindowFrameController.cs:77
static void AddElement(VisualElement newElement)
Adds a visual element to the window framework's root element with special handling for WindowFrame in...
Definition WindowFrameController.cs:2454
static void ApplyTooltips(VisualElement root)
Applies tooltip manipulators to UI elements within the specified root element.
Definition WindowFrameController.cs:1339
static WindowFrameController Instance
Gets the singleton instance of the WindowFrameController.
Definition WindowFrameController.cs:221

Member Function Documentation

◆ AddElement()

void GWG.WindowFramework.WindowFrameController.AddElement ( VisualElement newElement)
static
Parameters
newElementThe VisualElement to add to the framework

This method provides intelligent element addition with special logic for WindowFrame elements:

For WindowFrame elements:

  • Checks AllowMultipleInstances property
  • If false and an instance already exists, activates the existing instance instead of adding a duplicate
  • If true or no instance exists, adds the new element normally

For other VisualElements:

  • Adds directly to the root element

This prevents unintended window duplication while allowing multiple instances when desired.

// Add a regular UI element
var statusBar = new VisualElement();
// Add a window that allows multiple instances
var chatWindow = new ChatWindow { AllowMultipleInstances = true };
WindowFrameController.AddElement(chatWindow); // Always adds new instance
// Add a window that doesn't allow multiple instances
var settingsWindow = new SettingsWindow { AllowMultipleInstances = false };
WindowFrameController.AddElement(settingsWindow); // First call adds, subsequent calls activate existing
WindowFrameController.AddElement(new SettingsWindow()); // Activates the first one instead of adding

◆ AddGhostIcon()

void GWG.WindowFramework.WindowFrameController.AddGhostIcon ( )
private

⚠️ EXPERIMENTAL FEATURE: This method sets up a ghost icon element that can be used for drag-and-drop operations between windows, toolbars, or other UI elements.

The ghost icon is initially hidden and positioned absolutely to follow mouse movement during drag operations. It's semi-transparent to provide visual feedback without obscuring the drop target.

Configuration details:

  • Size: 50x50 pixels
  • Opacity: 50% (0.5f)
  • Position: Absolute positioning at (0,0)
  • Visibility: Hidden by default
  • Background: Transparent

This is not officially supported and the implementation may change.

// AddGhostIcon would be called internally if this feature were enabled
// Example of how it might be used in a drag system:
void StartDragOperation(VisualElement sourceIcon)
{
var controller = WindowFrameController.Instance;
controller.GhostIcon.style.backgroundImage = sourceIcon.style.backgroundImage;
controller.GhostIcon.style.visibility = Visibility.Visible;
// Update position during drag
RegisterCallback<MouseMoveEvent>(evt =>
{
controller.GhostIcon.style.left = evt.mousePosition.x;
controller.GhostIcon.style.top = evt.mousePosition.y;
});
}

◆ AddOrUpdateWindowData()

void GWG.WindowFramework.WindowFrameController.AddOrUpdateWindowData ( string dataKey,
WindowFrameData windowData )
Parameters
dataKeyUnique identifier for the window data, typically formatted as [Type]_[ParentObjectId]_[WindowId]
windowDataWindowFrameData object containing window state information

This method manages the window data dictionary that persists window states across application sessions. The data is only stored if MemoryEnabled is true.

The dataKey should be unique for each window instance and follow the format: [WindowType]_[ParentObjectId]_[WindowId]

The windowData contains information such as:

  • Window position and size
  • Open/closed state
  • Lock status
  • Custom window properties
// Add or update window data
var windowData = new WindowFrameData
{
windowId = "INV001",
title = "Inventory",
position = new Vector2(100, 200),
size = new Vector2(400, 300),
wasOpen = true,
locked = false
};
string key = "InventoryWindow_Player_INV001";
controller.AddOrUpdateWindowData(key, windowData);
// Data is automatically saved when application closes
Represents the serializable data structure for storing and loading window frame configuration and sta...
Definition WindowFrameData.cs:63

◆ ApplyThemeToPanel()

void GWG.WindowFramework.WindowFrameController.ApplyThemeToPanel ( IPanel panel,
List< StyleSheet > sheets )
private
Parameters
panelThe target panel to apply stylesheets to
sheetsList of stylesheets to apply

This method safely applies stylesheets to a panel by:

  1. Removing previously applied stylesheets tracked in _appliedStylesheets
  2. Adding each new stylesheet from the provided list
  3. Skipping null panels or stylesheets to prevent errors

The method ensures clean theme transitions by removing old styles before applying new ones, preventing style accumulation and conflicts.

// ApplyThemeToPanel is used internally by HandleThemeChanged
// Example of how it manages stylesheet cleanup and application:
// Before applying new theme:
// panel.styleSheets = [OldTheme.uss, OldGlobal.uss, UserCustom.uss]
// ApplyThemeToPanel removes: [OldTheme.uss, OldGlobal.uss]
// ApplyThemeToPanel adds: [NewTheme.uss, NewGlobal.uss]
// Result:
// panel.styleSheets = [UserCustom.uss, NewTheme.uss, NewGlobal.uss]

◆ ApplyTooltips() [1/2]

void GWG.WindowFramework.WindowFrameController.ApplyTooltips ( )
static

This overload automatically determines the scope of tooltip application based on the theme's apply method configuration:

  • AllPanels: Applies tooltips to all UIDocument panels in the scene
  • ParentPanel/WindowFramesOnly: Applies only to the controller's root element

Call this method after theme changes or when initializing the framework to ensure all UI elements have proper tooltip support.

// Refresh tooltips after theme change
// Apply tooltips during initialization
private void Start()
{
// Wait a frame for UI to initialize
StartCoroutine(ApplyTooltipsDelayed());
}
private IEnumerator ApplyTooltipsDelayed()
{
yield return null;
}

◆ ApplyTooltips() [2/2]

void GWG.WindowFramework.WindowFrameController.ApplyTooltips ( VisualElement root)
static
Parameters
rootThe parent VisualElement containing child elements that may need tooltips.

This method should be called whenever new UI content is instantiated to ensure tooltip functionality is properly attached. It automatically detects elements with tooltip text and adds the necessary manipulators.

The method prevents duplicate manipulators by checking element userData and only operates when tooltips are enabled in the framework.

// Apply tooltips to a newly loaded UXML document
var newPage = Resources.Load<VisualTreeAsset>("UI/NewPage");
var pageRoot = newPage.CloneTree();
myContainer.Add(pageRoot);
// Apply tooltips after programmatically creating elements
var button = new Button { text = "Click Me", tooltip = "This button does something" };
myContainer.Add(button);

◆ Awake()

void GWG.WindowFramework.WindowFrameController.Awake ( )
private

This method implements the singleton pattern, ensuring only one instance exists. It performs the following initialization steps:

  1. Establishes singleton instance and prevents destruction on scene load
  2. Loads saved window framework data from persistent storage
  3. Initializes the UIDocument component and root visual element
  4. Creates and configures the tooltip system
  5. Applies initial tooltip settings to existing UI elements

If multiple WindowFrameController components exist, only the first one becomes the singleton instance; others are automatically destroyed.

// The Awake method is called automatically by Unity
// No manual invocation is required or recommended
// Access the initialized instance after Awake
void Start()
{
{
Debug.Log("WindowFrameController is ready to use");
}
}

◆ BuildSheetList()

List< StyleSheet > GWG.WindowFramework.WindowFrameController.BuildSheetList ( )
Returns
List of StyleSheet objects including theme and global stylesheets in proper order

This method constructs the final stylesheet list by:

  1. Starting with the current theme's stylesheet
  2. Adding the global stylesheet based on GlobalsLoadOrder setting
    • First: Global stylesheet is inserted at the beginning
    • Last: Global stylesheet is appended at the end

The order affects CSS cascade priority - later stylesheets can override earlier ones where there are conflicts.

// BuildSheetList is called internally by CurrentThemeStylesheets
// Example of the ordering logic:
// If GlobalsLoadOrder = First:
// [0] GlobalStylesheet
// [1] CurrentStylesheet (theme)
// If GlobalsLoadOrder = Last:
// [0] CurrentStylesheet (theme)
// [1] GlobalStylesheet
var sheets = controller.BuildSheetList();
Debug.Log($"Total stylesheets: {sheets.Count}");

◆ ClearPreferences()

void GWG.WindowFramework.WindowFrameController.ClearPreferences ( bool forceAll = false)
Parameters
forceAllIf true, forces closure of all windows including locked ones.

This method performs a complete reset of the framework:

  • Closes all active windows (respecting lock state unless forceAll is true)
  • Clears all window position and size memory data
  • Resets all settings to default values
  • Removes all saved preferences

This is more destructive than ResetSettings() as it also removes window position memory and closes active windows.

// Complete reset with user confirmation
clearAllButton.clicked += () =>
{
if (EditorUtility.DisplayDialog("Clear All Data",
"This will close all windows and clear all saved data. Continue?",
"Clear All", "Cancel"))
{
}
};
// Gentle reset that respects locked windows
public void SoftReset()
{
controller.ClearPreferences(forceAll: false); // Won't close locked windows
}
void ClearPreferences(bool forceAll=false)
Clears all framework preferences and window memory, resetting everything to defaults.
Definition WindowFrameController.cs:1677

◆ FindActiveWindowFrame()

WindowFrame GWG.WindowFramework.WindowFrameController.FindActiveWindowFrame ( )
private
Returns
The first WindowFrame with Active = true, or null if none found.

This method searches through all WindowFrame elements in the RootElement and returns the first one that has its Active property set to true.

Used internally for window management operations that need to identify the currently active window. Returns null if no windows are active.

// FindActiveWindowFrame is used internally
// Direct usage example if method were public:
var activeWindow = FindActiveWindowFrame();
if (activeWindow != null)
{
Debug.Log($"Active window: {activeWindow.Title}");
}
else
{
Debug.Log("No active window found");
}
WindowFrame FindActiveWindowFrame()
Finds and returns the first active window frame.
Definition WindowFrameController.cs:1974

◆ FindFormostWindowFrame()

WindowFrame GWG.WindowFramework.WindowFrameController.FindFormostWindowFrame ( )
private
Returns
The last WindowFrame in the visual hierarchy, or null if none exist.

This method determines which window appears on top by finding the last WindowFrame in the child order of the RootElement. In UI Toolkit, later children appear in front of earlier children.

Used when determining which window should be active when no specific target is provided to SetActiveWindow().

// FindFormostWindowFrame is used internally
// Example of how visual hierarchy affects "foremost" determination:
// RootElement children order:
// [0] BackgroundWindow
// [1] InventoryWindow
// [2] SettingsWindow ← This is "foremost" (appears on top)
var foremost = FindFormostWindowFrame(); // Returns SettingsWindow
WindowFrame FindFormostWindowFrame()
Finds and returns the foremost (top-level) window frame in the UI hierarchy.
Definition WindowFrameController.cs:2011

◆ GetWindowData()

WindowFrameData GWG.WindowFramework.WindowFrameController.GetWindowData ( string dataKey)
Parameters
dataKeyUnique identifier for the window data, typically formatted as [Type]_[ParentObjectId]_[WindowId]
Returns
WindowFrameData object if found, null if not found or memory is disabled

This method retrieves previously saved window data for restoration purposes. Returns null if:

  • MemoryEnabled is false
  • The dataKey is null or empty
  • No data exists for the specified key

The dataKey should match the format used when storing data: [WindowType]_[ParentObjectId]_[WindowId]

// Retrieve window data for restoration
string windowKey = "InventoryWindow_Player_INV001";
var savedData = controller.GetWindowData(windowKey);
if (savedData != null)
{
// Restore window properties
myWindow.Title = savedData.title;
myWindow.SetPosition(savedData.position);
myWindow.SetSize(savedData.size);
myWindow.Locked = savedData.locked;
}
else
{
Debug.Log("No saved data found for window: " + windowKey);
}

◆ HandleThemeChanged()

void GWG.WindowFramework.WindowFrameController.HandleThemeChanged ( int newThemeIndex,
StyleSheet newStylesheet )
private
Parameters
newThemeIndexIndex of the new theme being applied
newStylesheetPrimary stylesheet of the new theme

This method responds to theme change events by:

  1. Building the complete stylesheet list for the new theme
  2. Applying stylesheets based on the ThemeApplyMethod setting:
    • ParentPanel: Applies to the controller's panel only
    • AllPanels: Applies to all UIDocument panels in the scene
    • WindowFramesOnly: Publishes event for individual window handling
  3. Triggering the OnThemeChanged event for subscribers
  4. Updating the active window focus state

The method ensures proper cleanup of previous stylesheets before applying new ones.

// HandleThemeChanged is called automatically when themes change
// Subscribe to the public event to respond to theme changes:
WindowFrameController.OnThemeChanged += (newSheets, oldSheets) =>
{
Debug.Log($"Theme changed: {newSheets?.Count} new sheets, {oldSheets?.Count} old sheets");
// Update custom UI elements that need manual theme handling
UpdateCustomElementStyles(newSheets);
};
static Action< List< StyleSheet >, List< StyleSheet > > OnThemeChanged
Event triggered when the application theme changes.
Definition WindowFrameController.cs:337

◆ HandleWindowFrameAdded()

void GWG.WindowFramework.WindowFrameController.HandleWindowFrameAdded ( WindowFrame window)
private
Parameters
windowThe WindowFrame instance that was added

This event handler is automatically called when any WindowFrame is added to the UI hierarchy. It performs the following actions:

  1. Logs the addition (commented out for performance)
  2. Ensures the window is tracked in ActiveWindowFrames if needed
  3. Schedules the window to be brought to front after UI updates complete

The delayed BringToFront() call ensures proper visual layering after the UI framework has processed the window addition.

// HandleWindowFrameAdded is called automatically
// It's triggered by WindowFrame.OnWindowFrameAdded event
// Example of when this is called:
var newWindow = new InventoryWindow();
RootElement.Add(newWindow); // Triggers WindowFrame.OnWindowFrameAdded
// → HandleWindowFrameAdded(newWindow) is called automatically
// → window.BringToFront() is scheduled for 5ms later
VisualElement RootElement
The root VisualElement that serves as the primary container for all UI elements.
Definition WindowFrameController.cs:241

◆ HandleWindowFrameRemoved()

void GWG.WindowFramework.WindowFrameController.HandleWindowFrameRemoved ( WindowFrame window)
private
Parameters
windowThe WindowFrame instance that was removed

This event handler is automatically called when any WindowFrame is removed from the UI hierarchy. It performs cleanup operations:

  1. Closes and clears any active tooltips
  2. Removes the window from ActiveWindowFrames list if present
  3. Updates the active window focus (typically to the next topmost window)

The cleanup ensures that UI state remains consistent after window removal and prevents references to destroyed windows.

// HandleWindowFrameRemoved is called automatically
// It's triggered by WindowFrame.OnWindowFrameRemoved event
// Example of when this is called:
var existingWindow = RootElement.Q<InventoryWindow>();
existingWindow.CloseWindow(); // Or existingWindow.RemoveFromHierarchy()
// → WindowFrame.OnWindowFrameRemoved is triggered
// → HandleWindowFrameRemoved(existingWindow) is called automatically
// → Tooltips are closed, active window is updated

◆ LoadWindowFrameworkData()

void GWG.WindowFramework.WindowFrameController.LoadWindowFrameworkData ( )
private

This method attempts to load saved data from a JSON file in the persistent data path. The loaded data includes:

  • Window positions, sizes, and states
  • Tooltip configuration (show delay, fade delay, fade type, etc.)
  • Context menu settings (fade delay, fade time)
  • Memory/persistence preferences
  • Active theme index

If the file doesn't exist or loading fails, default values are applied. The method gracefully handles corruption or missing data by falling back to defaults.

// LoadWindowFrameworkData is called automatically during Awake
// Manual invocation is not typically required
// Force reload data after external file modification
void ReloadSettings()
{
controller.LoadWindowFrameworkData(); // This is a private method
// Use public methods instead:
controller.ResetSettings(); // Or similar public alternatives
}

◆ OnDestroy()

void GWG.WindowFramework.WindowFrameController.OnDestroy ( )
private

This method performs comprehensive cleanup operations:

  • Cleans up player themes if enabled in theme data
  • Unsubscribes from all event handlers to prevent memory leaks
  • Saves window framework data to persistent storage
  • Clears the singleton instance reference

The cleanup ensures that user preferences and window states are preserved across application sessions while properly releasing all resources.

// OnDestroy is called automatically by Unity
// Manual invocation is not required
// Example of data that gets saved during destruction
void SaveCustomData()
{
// Window positions, sizes, and states
// Theme preferences and settings
// Tooltip and context menu configuration
// All saved to: Application.persistentDataPath + "/" + dataFileName
}

◆ OnDisable()

void GWG.WindowFramework.WindowFrameController.OnDisable ( )
private

This method prevents memory leaks and unintended behavior by properly unsubscribing from all event handlers when the component becomes inactive.

Events unsubscribed include:

  • Theme change events from theme data
  • WindowFrame addition and removal events

This is essential for proper cleanup in Unity's component lifecycle.

// OnDisable is called automatically by Unity
// Manual invocation is not required
// Example of proper event cleanup pattern
void OnDestroy()
{
// Always unsubscribe from events to prevent memory leaks
if (someEventSource != null)
someEventSource.OnSomeEvent -= HandleEvent;
}
void OnDestroy()
Handles cleanup and data persistence when the component is destroyed.
Definition WindowFrameController.cs:1284

◆ OnEnable()

void GWG.WindowFramework.WindowFrameController.OnEnable ( )
private

This method handles the following initialization tasks:

  • Subscribes to theme change events if theme data is available
  • Validates that a default stylesheet is assigned when no theme data exists
  • Subscribes to WindowFrame addition and removal events
  • Triggers an initial theme change to apply current theme settings

The method ensures proper event subscription for theme management and validates essential configuration to prevent runtime errors.

// OnEnable is called automatically by Unity
// Manual invocation is not required
// Example of how theme changes are handled after OnEnable
WindowFrameController.OnThemeChanged += (newSheets, oldSheets) =>
{
Debug.Log("Theme applied after OnEnable initialization");
};

◆ OpenSettingsWindow()

void GWG.WindowFramework.WindowFrameController.OpenSettingsWindow ( )

The settings window allows users to adjust:

  • Theme selection and preferences
  • Tooltip timing and behavior
  • Context menu settings
  • Memory/persistence options
  • Other framework configuration options

The settings window is a WindowFrame instance and follows the same behavior patterns as other framework windows.

// Add settings button to your UI
settingsButton.clicked += () =>
{
};
// Open settings programmatically
if (Input.GetKeyDown(KeyCode.F1))
{
}
void OpenSettingsWindow()
Opens the built-in settings window for configuring the window framework.
Definition WindowFrameController.cs:1447

◆ ReopenWindows()

void GWG.WindowFramework.WindowFrameController.ReopenWindows ( float delay = 0::1f)
Parameters
delayDelay in seconds before beginning window restoration. Default: 0.1f

This method should be called at an appropriate point during application startup when you want saved windows to be restored. The delay allows the UI framework and other systems to fully initialize before creating window instances.

Only windows that were open when the application last closed will be restored, and only if MemoryEnabled is true. Window positions, sizes, and other properties are restored from the saved data.

// Restore windows after scene load
void Start()
{
// Wait for UI to initialize, then restore windows
}
// Immediate restoration (shorter delay)
void OnSceneLoaded()
{
}
// Custom timing for specific scenarios
IEnumerator RestoreWindowsWhenReady()
{
yield return new WaitUntil(() => UISystemReady());
WindowFrameController.Instance?.ReopenWindows();
}
void ReopenWindows(float delay=0.1f)
Restores previously opened windows from saved data after a specified delay.
Definition WindowFrameController.cs:1775

◆ ReopenWindowsDelayed()

System.Collections.IEnumerator GWG.WindowFramework.WindowFrameController.ReopenWindowsDelayed ( float delay = 0::1f)
private
Parameters
delayDelay in seconds before calling ReopenWindowsInternal.
Returns
Coroutine that waits for the specified delay then restores windows.

This coroutine provides the delay mechanism for ReopenWindows(). It waits for the specified time period, then calls ReopenWindowsInternal() to perform the actual window restoration logic.

The delay is essential to ensure that:

  • UI systems are fully initialized
  • Theme data is loaded and applied
  • All required components are ready
// This coroutine is used internally by ReopenWindows()
// Direct usage is not typically required:
// Internal flow:
ReopenWindows(0.5f) →
StartCoroutine(ReopenWindowsDelayed(0.5f)) →
yield return new WaitForSeconds(0.5f) →
void ReopenWindowsInternal()
Performs the actual window restoration from saved data.
Definition WindowFrameController.cs:1844
System.Collections.IEnumerator ReopenWindowsDelayed(float delay=0.1f)
Internal coroutine that handles delayed window restoration.
Definition WindowFrameController.cs:1807

◆ ReopenWindowsInternal()

void GWG.WindowFramework.WindowFrameController.ReopenWindowsInternal ( )

This method recreates window instances from saved WindowFrameSettingsData:

  1. Checks if memory is enabled (returns early if disabled)
  2. Iterates through all saved window data entries
  3. Filters for windows that were open when saved (wasOpen = true)
  4. Uses reflection to instantiate the correct window type from saved type string
  5. Restores window properties (ID, position, size, title, etc.)
  6. Adds restored windows to the UI hierarchy

Window types must be accessible via Type.GetType() for restoration to work. If a window type is not found, a warning is logged and that window is skipped.

// ReopenWindowsInternal is called automatically by ReopenWindows()
// Direct usage is not typically required
// Example of data that gets restored:
// - Window type: "MyNamespace.InventoryWindow"
// - Window ID: "Inventory_Player_001"
// - Position: {x: 100, y: 200}
// - Size: {width: 400, height: 300}
// - Title: "Player Inventory"
// - Lock state, start position, etc.

◆ ResetSettings()

void GWG.WindowFramework.WindowFrameController.ResetSettings ( )

This method resets the following settings to their default values:

  • Theme selection (reverts to default theme if theme data exists)
  • Tooltip timing and behavior settings
  • Context menu timing settings
  • Memory/persistence state
  • Other framework preferences

Window position and size data in WindowFrameSettingsData is preserved, allowing users to reset preferences without losing window arrangements.

// Reset settings from a menu option
resetButton.clicked += () =>
{
if (EditorUtility.DisplayDialog("Reset Settings",
"Reset all framework settings to defaults? Window positions will be preserved.",
"Reset", "Cancel"))
{
}
};
// Reset settings programmatically
public void RestoreDefaultConfiguration()
{
WindowFrameController.Instance?.ResetSettings();
Debug.Log("Framework settings reset to defaults");
}
void ResetSettings()
Resets all framework settings to their default values while preserving window memory data.
Definition WindowFrameController.cs:1631

◆ SaveWindowFrameworkData()

void GWG.WindowFramework.WindowFrameController.SaveWindowFrameworkData ( )
private

This method serializes the current framework state to JSON format and saves it to the persistent data path. The saved data includes:

  • All window frame settings and states from WindowFrameSettingsData
  • Tooltip configuration (delays, fade settings, enabled state)
  • Context menu settings (delays, fade timing)
  • Active theme index and preferences
  • Memory/persistence state

The save operation is automatically performed during component destruction to ensure user preferences persist across application sessions.

// SaveWindowFrameworkData is called automatically during OnDestroy
// Manual invocation is not typically required
// Force save current state (if method were public)
void SaveCurrentSettings()
{
// This is a private method - no direct access
// Settings are automatically saved when application closes
// Alternative: Modify settings through public properties
controller.TooltipShowDelay = newValue; // Automatically saved later
}

◆ SetActiveWindow()

void GWG.WindowFramework.WindowFrameController.SetActiveWindow ( WindowFrame newTarget)
Parameters
newTargetThe window frame to set as active. If null, the foremost window is activated.

This method manages window focus and visual state:

  1. If newTarget is null, finds the foremost (top) window to activate
  2. Deactivates all currently active windows
  3. Activates the target window
  4. Brings the target window to the front of the UI hierarchy

Active windows typically receive different styling (via CSS) to indicate focus. Only one window should be active at a time to provide clear user feedback.

// Set a specific window as active
var inventoryWindow = FindWindowByType<InventoryWindow>();
// Activate the topmost window (pass null)
// Handle window click to activate
window.RegisterCallback<ClickEvent>(evt =>
{
});
void SetActiveWindow(WindowFrame newTarget)
Sets the specified window as the active window and deactivates all others.
Definition WindowFrameController.cs:1921

◆ SetActiveWindowDelayed()

void GWG.WindowFramework.WindowFrameController.SetActiveWindowDelayed ( WindowFrame newTarget,
int delay = 5 )
private
Parameters
newTargetThe window to activate.
delayDelay in milliseconds before activation. Default: 5ms

This method uses Unity's scheduling system to delay window activation, allowing the UI to complete any pending updates before changing focus.

The delay is typically very short (5ms) and is used to ensure proper timing in the UI update cycle, especially after window creation or modification operations.

// SetActiveWindowDelayed is used internally
// Typical usage pattern within the framework:
// After creating a new window
var newWindow = new MyWindow();
RootElement.Add(newWindow);
SetActiveWindowDelayed(newWindow, 5); // Activate after UI updates
// Custom delay for special scenarios
SetActiveWindowDelayed(targetWindow, 100); // Longer delay if needed
void SetActiveWindowDelayed(WindowFrame newTarget, int delay=5)
Sets the active window after a specified delay.
Definition WindowFrameController.cs:2049

◆ SetDefaultValues()

void GWG.WindowFramework.WindowFrameController.SetDefaultValues ( )
private

This private method initializes or resets all framework settings to the default values defined by constants at the top of the class:

  • TooltipShowDelayDefault
  • TooltipFadeDelayDefault
  • TooltipFadeTypeDefault
  • TooltipFadeTimeDefault
  • ContextMenuFadeDelayDefault
  • ContextMenuFadeTimeDefault
  • MemoryEnabledDefault
  • TooltipsEnabledDefault

Called during initialization when no saved data exists, or when loading saved data fails, or when explicitly resetting settings.

// SetDefaultValues is called internally by:
// - LoadWindowFrameworkData (when file missing/corrupt)
// - ResetSettings (when user resets)
// - ClearPreferences (during complete reset)
// Values set match these constants:
TooltipShowDelay = 2f; // TooltipShowDelayDefault
TooltipFadeDelay = 0.75f; // TooltipFadeDelayDefault
TooltipFadeType = FadeInAndOut; // TooltipFadeTypeDefault
// ... etc
TooltipFadeType TooltipFadeType
Gets or sets the type of fade animation for tooltips.
Definition WindowFrameController.cs:846
float TooltipShowDelay
Gets or sets the delay before showing tooltips when hovering over elements.
Definition WindowFrameController.cs:772
float TooltipFadeDelay
Gets or sets the delay before tooltips begin fading out.
Definition WindowFrameController.cs:808
@ FadeInAndOut
Tooltip fades in when shown and fades out when hidden. Provides the smoothest visual experience with ...
Definition WindowFrameTooltip.cs:47

◆ Update()

void GWG.WindowFramework.WindowFrameController.Update ( )
private

This method performs the following maintenance tasks:

  • Ensures tooltips remain in front of windows when visible
  • Reinitializes the root element if it becomes null (helps with some scene changes)
  • Validates UIDocument component reference

The method only operates during play mode to avoid edit-mode errors. It handles edge cases where UI components might be destroyed or reassigned.

// Update is called automatically by Unity each frame
// No manual invocation is required
// Monitor tooltip visibility state during runtime
void LateUpdate()
{
{
bool isVisible = WindowFrameController.WindowFrameTooltip.resolvedStyle.visibility != Visibility.Hidden;
// Tooltip visibility is managed automatically in Update
}
}
static WindowFrameTooltip WindowFrameTooltip
Gets or sets the static tooltip system instance.
Definition WindowFrameController.cs:672

Member Data Documentation

◆ _appliedStylesheets

List<StyleSheet> GWG.WindowFramework.WindowFrameController._appliedStylesheets = new List<StyleSheet>()
private

Used internally to track which stylesheets are currently applied to panels so they can be properly removed when themes change.

◆ _clickAction

InputAction GWG.WindowFramework.WindowFrameController._clickAction
private

This action is used internally to manage UI interactions and window focus changes. It's automatically configured during the controller's initialization.

◆ _ghostIcon

VisualElement GWG.WindowFramework.WindowFrameController._ghostIcon
private

A VisualElement representing a draggable ghost icon, or null if not active.

⚠️ EXPERIMENTAL FEATURE: This is not a supported feature and is provided only as an example of how to implement icon dragging between windows or toolbars.

The ghost icon provides visual feedback during drag operations, showing a semi-transparent representation of the item being dragged. This can be used with custom drag manipulators to create rich drag-and-drop interactions.

Use at your own risk - this API may change or be removed in future versions.

// Example usage with a custom drag manipulator
var dragManipulator = new MyIconDragManipulator();
dragManipulator.OnDragStart += (iconData) =>
{
// Setup ghost icon
var controller = WindowFrameController.Instance;
if (controller.GhostIcon != null)
{
controller.GhostIcon.style.backgroundImage = iconData.image;
controller.GhostIcon.style.visibility = Visibility.Visible;
}
};

◆ _windowFrameTooltip

WindowFrameTooltip GWG.WindowFramework.WindowFrameController._windowFrameTooltip
staticprivate

◆ contextMenuFadeDelay

float GWG.WindowFramework.WindowFrameController.contextMenuFadeDelay = ContextMenuFadeDelayDefault
private

◆ ContextMenuFadeDelayDefault

const float GWG.WindowFramework.WindowFrameController.ContextMenuFadeDelayDefault = 0.75f
staticprivate

◆ contextMenuFadeTime

float GWG.WindowFramework.WindowFrameController.contextMenuFadeTime = ContextMenuFadeTimeDefault
private

◆ ContextMenuFadeTimeDefault

const float GWG.WindowFramework.WindowFrameController.ContextMenuFadeTimeDefault = 0.5f
staticprivate

◆ dataFileName

string GWG.WindowFramework.WindowFrameController.dataFileName = "WindowFrameData.json"
private

The name of the JSON file where window and framework settings are stored. Default: "WindowFrameData.json"

This file is created in Application.persistentDataPath and contains:

  • Window positions and sizes
  • Theme preferences
  • Tooltip and context menu settings
  • Other framework configuration data

Change this value if you need to use a different filename or want to separate data for different game modes or users.

// Use custom filename for different game modes
controller.dataFileName = "MainMenuWindowData.json";
// Include version in filename
controller.dataFileName = $"WindowData_v{Application.version}.json";

◆ defaultStyleSheet

StyleSheet GWG.WindowFramework.WindowFrameController.defaultStyleSheet
private

◆ globalsLoadOrder

GlobalsLoadOrder GWG.WindowFramework.WindowFrameController.globalsLoadOrder
private

◆ globalStyleSheet

StyleSheet GWG.WindowFramework.WindowFrameController.globalStyleSheet
private

◆ memoryEnabled

bool GWG.WindowFramework.WindowFrameController.memoryEnabled = true
private

◆ MemoryEnabledDefault

const bool GWG.WindowFramework.WindowFrameController.MemoryEnabledDefault = true
staticprivate

◆ RootElement

VisualElement GWG.WindowFramework.WindowFrameController.RootElement

This element is automatically assigned from the attached UIDocument component during initialization. It acts as the parent container for all window frames, tooltips, and other UI components managed by the framework.

// Add elements directly to the root
var myElement = new VisualElement();
// Query elements in the root
var buttons = WindowFrameController.Instance.RootElement.Query<Button>().ToList();

◆ themeData

WindowFrameThemeData GWG.WindowFramework.WindowFrameController.themeData

This ScriptableObject contains all theme definitions, stylesheets, and theme switching logic. When assigned, it enables dynamic theme switching and provides the current theme's stylesheets. If not assigned, the framework falls back to using the default stylesheet.

// Assign theme data at runtime
controller.themeData = Resources.Load<WindowFrameThemeData>("Themes/MainThemes");
// Switch themes programmatically
if (controller.themeData != null)
{
controller.themeData.SetActiveTheme(1); // Switch to second theme
}
Represents a theme data asset for configuring and managing window frame themes in the Window Framewor...
Definition WindowFrameThemeData.cs:141

◆ tooltipFadeDelay

float GWG.WindowFramework.WindowFrameController.tooltipFadeDelay = TooltipFadeDelayDefault
private

◆ TooltipFadeDelayDefault

const float GWG.WindowFramework.WindowFrameController.TooltipFadeDelayDefault = 0.75f
staticprivate

◆ tooltipFadeTime

float GWG.WindowFramework.WindowFrameController.tooltipFadeTime = TooltipFadeTimeDefault
private

◆ TooltipFadeTimeDefault

const float GWG.WindowFramework.WindowFrameController.TooltipFadeTimeDefault = 0.5f
staticprivate

◆ tooltipFadeType

TooltipFadeType GWG.WindowFramework.WindowFrameController.tooltipFadeType = TooltipFadeType.FadeOut
private

◆ TooltipFadeTypeDefault

const TooltipFadeType GWG.WindowFramework.WindowFrameController.TooltipFadeTypeDefault = TooltipFadeType.FadeInAndOut
staticprivate

◆ tooltipsEnabled

bool GWG.WindowFramework.WindowFrameController.tooltipsEnabled = true
private

◆ TooltipsEnabledDefault

const bool GWG.WindowFramework.WindowFrameController.TooltipsEnabledDefault = true
staticprivate

◆ tooltipShowDelay

float GWG.WindowFramework.WindowFrameController.tooltipShowDelay = TooltipShowDelayDefault
private

◆ TooltipShowDelayDefault

const float GWG.WindowFramework.WindowFrameController.TooltipShowDelayDefault = 2
staticprivate

◆ uiDocument

UIDocument GWG.WindowFramework.WindowFrameController.uiDocument
private

This component provides the root visual element and is automatically retrieved if not assigned. The UIDocument component is required for the WindowFrameController to function properly.

// Access the UIDocument directly if needed
var rootElement = document.rootVisualElement;
UIDocument uiDocument
The primary UIDocument component attached to this GameObject.
Definition WindowFrameController.cs:292

◆ uiDocuments

List<UIDocument> GWG.WindowFramework.WindowFrameController.uiDocuments = new List<UIDocument>()
private

These documents can be used for managing multiple UI panels or documents within the framework. Useful for complex UI setups with multiple documents that need coordinated theme management.

// Add additional UI documents for theme management
var additionalDoc = GameObject.Find("SecondaryUI").GetComponent<UIDocument>();
controller.uiDocuments.Add(additionalDoc);

◆ WindowFrameSettingsData

Dictionary<string, WindowFrameData> GWG.WindowFramework.WindowFrameController.WindowFrameSettingsData = new Dictionary<string, WindowFrameData>()

A dictionary where keys are window identifiers and values are WindowFrameData objects containing window settings, position, size, and state information.

This data is used for persistence across application sessions when memory is enabled. The key format is typically: [WindowType]_[ParentObjectId]_[WindowId]

The dictionary is automatically populated from saved data during initialization and updated during runtime as windows are modified.

// Access window data programmatically
string windowKey = "MyWindow_MainUI_001";
var windowData = controller.WindowFrameSettingsData[windowKey];
// Check if window data exists
if (controller.WindowFrameSettingsData.ContainsKey(windowKey))
{
var data = controller.WindowFrameSettingsData[windowKey];
Debug.Log($"Window {data.title} was at position {data.position}");
}

Property Documentation

◆ ActiveThemeIndex

int GWG.WindowFramework.WindowFrameController.ActiveThemeIndex
get

The zero-based index of the active theme from the theme data. Returns 0 if no theme data is assigned.

Debug.Log($"Current theme index: {currentTheme}");
int ActiveThemeIndex
Gets the index of the currently active theme.
Definition WindowFrameController.cs:120

◆ ActiveWindowFrames

List<WindowFrame> GWG.WindowFramework.WindowFrameController.ActiveWindowFrames
get

A list of WindowFrame instances currently present in the UI hierarchy. The list is dynamically generated from the current UI state.

This property queries the UI hierarchy in real-time, so the returned list reflects the current state of active windows. The list may change between calls as windows are opened and closed.

// Get all active windows
Debug.Log($"Currently {activeWindows.Count} windows are open");
// Close all windows
foreach (var window in activeWindows)
{
window.CloseWindow();
}
List< WindowFrame > ActiveWindowFrames
Gets a list of all currently active window frames in the framework.
Definition WindowFrameController.cs:382

◆ ContextMenuDelay

int GWG.WindowFramework.WindowFrameController.ContextMenuDelay
getset

The delay in milliseconds before context menu appearance.

This property is deprecated and will be removed in future versions. Use ContextMenuFadeDelay instead.

// Old way (deprecated)
controller.ContextMenuDelay = 1000;
// New way
controller.ContextMenuFadeDelay = 1.0f;

◆ ContextMenuFadeDelay

float GWG.WindowFramework.WindowFrameController.ContextMenuFadeDelay
getset

The delay in seconds before context menu fade-out begins after mouse leaves the menu area. Range: 0 to 5 seconds.

Context menus close immediately on click regardless of this setting. This delay allows users to temporarily move the mouse outside the menu without it disappearing immediately, improving usability.

// Quick fade for responsive menus
controller.ContextMenuFadeDelay = 0.3f;
// Longer delay for forgiving interaction
controller.ContextMenuFadeDelay = 1.0f;

◆ ContextMenuFadeTime

float GWG.WindowFramework.WindowFrameController.ContextMenuFadeTime
getset

The duration in seconds for context menu fade-out animation. Range: 0 to 3 seconds.

Context menus appear instantly; this only affects fade-out timing. Controls how smoothly context menus disappear when closing. Set to 0 for instant disappearance.

// Instant disappearance
controller.ContextMenuFadeTime = 0f;
// Smooth fade out
controller.ContextMenuFadeTime = 0.4f;

◆ CurrentStylesheet

StyleSheet GWG.WindowFramework.WindowFrameController.CurrentStylesheet
get

The main StyleSheet object for the currently active theme. Returns the default stylesheet if no theme data is configured.

This property provides quick access to the main theme stylesheet without including global or additional stylesheets. Use CurrentThemeStylesheets if you need the complete list including global styles.

// Apply just the main theme stylesheet
var mainSheet = controller.CurrentStylesheet;
if (mainSheet != null)
{
myElement.styleSheets.Add(mainSheet);
}

◆ CurrentThemeStylesheets

List<StyleSheet> GWG.WindowFramework.WindowFrameController.CurrentThemeStylesheets
get

A list of StyleSheet objects representing the current theme's styling. Includes the base theme stylesheet and global stylesheet based on load order settings.

If no theme data is available, returns a list containing only the default stylesheet. The order of stylesheets in the list affects CSS cascade and style precedence.

// Get current theme stylesheets
var currentSheets = controller.CurrentThemeStylesheets;
Debug.Log($"Current theme uses {currentSheets.Count} stylesheets");
// Apply to a specific panel
foreach (var sheet in currentSheets)
{
myPanel.styleSheets.Add(sheet);
}

◆ DefaultStylesheet

StyleSheet GWG.WindowFramework.WindowFrameController.DefaultStylesheet
getset

The StyleSheet object to use as fallback styling. This stylesheet is applied when no theme data is available.

This serves as the fallback styling for the framework when theme support is disabled or no specific theme is selected. It ensures that UI elements always have basic styling available.

// Set a default stylesheet programmatically
controller.DefaultStylesheet = Resources.Load<StyleSheet>("UI/DefaultTheme");
// Check if default stylesheet is assigned
if (controller.DefaultStylesheet == null)
{
Debug.LogWarning("No default stylesheet assigned!");
}

◆ GhostIcon

VisualElement GWG.WindowFramework.WindowFrameController.GhostIcon
getset

◆ GlobalsLoadOrder

GlobalsLoadOrder GWG.WindowFramework.WindowFrameController.GlobalsLoadOrder
getset

A GlobalsLoadOrder value determining whether global styles are applied before (First) or after (Last) theme-specific stylesheets.

This setting affects CSS cascade and style precedence:

  • First: Theme styles can override global styles
  • Last: Global styles can override theme styles

Choose based on whether you want themes to be able to override your global styling or vice versa.

// Let themes override global styles
controller.GlobalsLoadOrder = GlobalsLoadOrder.First;
// Let global styles override themes
controller.GlobalsLoadOrder = GlobalsLoadOrder.Last;
GlobalsLoadOrder GlobalsLoadOrder
Gets or sets the loading order for global stylesheet relative to theme stylesheets.
Definition WindowFrameController.cs:633

◆ GlobalStylesheet

StyleSheet GWG.WindowFramework.WindowFrameController.GlobalStylesheet
getset

A StyleSheet that is always applied regardless of the current theme. Can be null if no global styling is needed.

The global stylesheet provides consistent styling elements that should appear the same across all themes. Its load order relative to theme stylesheets is controlled by the GlobalsLoadOrder property.

This is useful for defining common UI patterns, animations, or framework-specific styles that shouldn't change with themes.

// Set global stylesheet for consistent framework styling
controller.GlobalStylesheet = Resources.Load<StyleSheet>("UI/GlobalFramework");
// Control load order for style precedence
controller.GlobalsLoadOrder = GlobalsLoadOrder.Last; // Global styles override theme styles

◆ Instance

WindowFrameController GWG.WindowFramework.WindowFrameController.Instance
staticgetprivate set

The active WindowFrameController instance in the scene. Returns null if no instance exists.

This instance is automatically created when the first WindowFrameController component is initialized and persists across scene changes.

// Check if instance exists before using
{
}

◆ MemoryEnabled

bool GWG.WindowFramework.WindowFrameController.MemoryEnabled
getset

True to enable automatic saving and loading of window positions, sizes, and states. False to disable persistence features.

When enabled, the framework automatically:

  • Saves window positions, sizes, and states to disk
  • Restores window states when the application starts
  • Maintains user preferences across sessions

Data is saved to the persistent data path in JSON format. Disabling this feature improves performance but loses state persistence.

// Enable persistence for production builds
controller.MemoryEnabled = true;
// Disable for development or testing
controller.MemoryEnabled = false;
// Check if persistence is enabled before saving custom data
if (controller.MemoryEnabled)
{
// Safe to use persistence features
controller.AddOrUpdateWindowData(windowKey, windowData);
}

◆ TooltipDelay

int GWG.WindowFramework.WindowFrameController.TooltipDelay
getset

The delay in milliseconds before tooltip behavior.

This property is deprecated and will be removed in future versions. Use TooltipShowDelay or TooltipFadeDelay instead.

// Old way (deprecated)
controller.TooltipDelay = 2000;
// New way
controller.TooltipShowDelay = 2.0f;
controller.TooltipFadeDelay = 0.75f;

◆ TooltipFadeDelay

float GWG.WindowFramework.WindowFrameController.TooltipFadeDelay
getset

The delay in seconds before tooltip fade-out animation begins. Range: 0 to 5 seconds.

This controls how long a tooltip remains fully visible before starting to fade away. Longer delays give users more time to read tooltip content. Set to 0 for immediate fade-out when hover ends.

// Quick fade for minimal UI distraction
controller.TooltipFadeDelay = 0.25f;
// Longer delay for complex tooltip content
controller.TooltipFadeDelay = 1.5f;

◆ TooltipFadeTime

float GWG.WindowFramework.WindowFrameController.TooltipFadeTime
getset

The duration in seconds for fade-in and fade-out animations. Range: 0 to 3 seconds.

Determines how long fade animations take to complete. Shorter times create snappy animations, while longer times create smoother, more gradual transitions. Only applies when TooltipFadeType includes fade effects.

// Quick, snappy fades
controller.TooltipFadeTime = 0.2f;
// Smooth, gradual fades
controller.TooltipFadeTime = 0.8f;

◆ TooltipFadeType

TooltipFadeType GWG.WindowFramework.WindowFrameController.TooltipFadeType
getset

The TooltipFadeType enum value specifying fade behavior. Options include FadeIn, FadeOut, FadeInAndOut, or None.

Controls the visual appearance and disappearance of tooltips:

  • FadeIn: Smooth appearance, instant disappearance
  • FadeOut: Instant appearance, smooth disappearance
  • FadeInAndOut: Smooth appearance and disappearance
  • None: Instant appearance and disappearance
// Smooth both directions
controller.TooltipFadeType = TooltipFadeType.FadeInAndOut;
// Quick appearance, smooth disappearance
controller.TooltipFadeType = TooltipFadeType.FadeOut;

◆ TooltipsActive

bool GWG.WindowFramework.WindowFrameController.TooltipsActive
getset

True if tooltips should be displayed and functional; false to disable tooltip system.

When set to false, existing tooltip manipulators remain but tooltips won't be shown. When set to true, automatically searches for and initializes the tooltip system.

The tooltip system is automatically initialized during framework startup but can be toggled on/off during runtime as needed.

// Disable tooltips temporarily
controller.TooltipsActive = false;
// Re-enable tooltips
controller.TooltipsActive = true;
// Check tooltip status
if (controller.TooltipsActive)
{
Debug.Log("Tooltips are currently enabled");
}

◆ TooltipShowDelay

float GWG.WindowFramework.WindowFrameController.TooltipShowDelay
getset

The delay in seconds before a tooltip appears after mouse hover begins. Range: 0 to 5 seconds.

This delay prevents tooltips from appearing immediately on hover, reducing visual noise and only showing tooltips for deliberate hover actions. Shorter delays make tooltips more responsive but potentially more intrusive.

// Quick tooltips for power users
controller.TooltipShowDelay = 0.5f;
// Slower tooltips to reduce distraction
controller.TooltipShowDelay = 2.0f;

◆ UIRoot

VisualElement GWG.WindowFramework.WindowFrameController.UIRoot
staticget

The root container VisualElement for all UI components. Returns null if no instance exists.

This provides static access to the UI root without needing to reference the instance directly. All window frames and UI elements are added as children of this root element.

// Add a custom element to the UI root
var myElement = new VisualElement();
WindowFrameController.UIRoot?.Add(myElement);
// Query for elements in the UI hierarchy
var allButtons = WindowFrameController.UIRoot?.Query<Button>().ToList();
static VisualElement UIRoot
Gets the root VisualElement for the window framework's UI hierarchy.
Definition WindowFrameController.cs:265

◆ WindowFrameTooltip

WindowFrameTooltip GWG.WindowFramework.WindowFrameController.WindowFrameTooltip
staticgetset

The WindowFrameTooltip instance managing tooltip display and behavior. Returns null if tooltips are disabled or not initialized.

This provides static access to the tooltip system for displaying contextual help information. The tooltip instance is automatically created and managed by the WindowFrameController.

// Show a custom tooltip programmatically
{
WindowFrameController.WindowFrameTooltip.ShowTooltip("Custom message", mousePosition);
}

Event Documentation

◆ OnThemeChanged

Action<List<StyleSheet>, List<StyleSheet> > GWG.WindowFramework.WindowFrameController.OnThemeChanged
static

The first parameter contains the new stylesheets to apply. The second parameter contains the previously applied stylesheets.

This event is useful for UI elements that need to respond to theme changes by updating their appearance or refreshing their styling.

// Subscribe to theme changes
WindowFrameController.OnThemeChanged += (newSheets, oldSheets) =>
{
Debug.Log($"Theme changed: {newSheets.Count} new stylesheets applied");
// Update custom UI elements here
RefreshCustomElements();
};