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

Represents the serializable data structure for storing and loading window frame configuration and state information. This class contains all the essential properties needed to persist window settings between application sessions. More...

Public Attributes

Vector2 location
 Gets or sets the screen position of the window frame.
bool locked
 Gets or sets a value indicating whether the window frame is locked in position and/or size.
bool lockedToStartPosition
 Gets or sets a value indicating whether the window is constrained to its initial start position.
string name
 Gets or sets the internal name of the window frame.
float opacity
 Gets or sets the opacity (transparency) level of the window frame.
string parentObjectId
 Gets or sets the identifier of the parent object that owns or contains this window frame.
Vector2 size
 Gets or sets the dimensions (width and height) of the window frame.
string title
 Gets or sets the display title of the window frame.
bool visible
 Gets or sets a value indicating whether the window frame is currently visible.
bool wasOpen
 Gets or sets a value indicating whether the window was open during the last application session.
WindowFramePosition windowFrameStartPosition
 Gets or sets the designated start position for the window frame.
string windowId
 Gets or sets the unique identifier for the window frame.
string windowType
 Gets or sets the type classification of the window frame.

Detailed Description

The WindowFrameData class is designed to work with Unity's serialization system and supports automatic loading and saving of window frame properties. The serialization system automatically handles the addition of new variables to existing save files, making it extensible for future enhancements.

Supported Data Types:
The serialization system supports the following basic types:

  • int - Integer values
  • float - Floating-point values
  • string - Text strings
  • bool - Boolean values
  • Vector2 - 2D vector coordinates
  • Vector3 - 3D vector coordinates
  • Color - Color values
  • Rect - Rectangle definitions

Extensibility:
When adding new properties to this class, you must implement the corresponding logic to handle the data loading and application of the new properties in the window frame system.

// Create a new window frame data instance
var windowData = new WindowFrameData
{
windowId = "MainWindow_001",
name = "Main Application Window",
title = "My Application v1.0",
windowType = "MainWindow",
location = new Vector2(100, 50),
size = new Vector2(800, 600),
opacity = 1.0f,
visible = true,
locked = false
};
// Serialize to JSON for saving
string json = JsonUtility.ToJson(windowData, true);
// Deserialize from JSON for loading
var loadedData = JsonUtility.FromJson<WindowFrameData>(json);
Represents the serializable data structure for storing and loading window frame configuration and sta...
Definition WindowFrameData.cs:63
string title
Gets or sets the display title of the window frame.
Definition WindowFrameData.cs:200
Vector2 size
Gets or sets the dimensions (width and height) of the window frame.
Definition WindowFrameData.cs:443
bool visible
Gets or sets a value indicating whether the window frame is currently visible.
Definition WindowFrameData.cs:496
float opacity
Gets or sets the opacity (transparency) level of the window frame.
Definition WindowFrameData.cs:388
Vector2 location
Gets or sets the screen position of the window frame.
Definition WindowFrameData.cs:290
string windowId
Gets or sets the unique identifier for the window frame.
Definition WindowFrameData.cs:94
bool locked
Gets or sets a value indicating whether the window frame is locked in position and/or size.
Definition WindowFrameData.cs:338
string name
Gets or sets the internal name of the window frame.
Definition WindowFrameData.cs:164
string windowType
Gets or sets the type classification of the window frame.
Definition WindowFrameData.cs:244

Member Data Documentation

◆ location

Vector2 GWG.WindowFramework.WindowFrameData.location

A Vector2 representing the window's position in screen coordinates. Typically measured in pixels from the top-left corner of the screen or parent container.

The location property determines where the window appears on the screen and is used for:

  • Restoring window positions between application sessions
  • Implementing window layout management
  • Preventing windows from appearing off-screen
  • Coordinating multi-window arrangements

Coordinate System:
The coordinate system typically follows screen space conventions where:

  • X increases from left to right
  • Y increases from top to bottom (may vary based on UI system)
  • Origin (0,0) is usually at the top-left corner
// Position window at specific screen coordinates
windowData.location = new Vector2(100, 50);
// Center window on screen (assuming 1920x1080 resolution)
var screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
var windowCenter = windowData.size / 2f;
windowData.location = screenCenter - windowCenter;
// Position relative to another window
windowData.location = mainWindow.location + new Vector2(50, 30);
// Validate location is on screen
windowData.location.x = Mathf.Clamp(windowData.location.x, 0, Screen.width - windowData.size.x);
windowData.location.y = Mathf.Clamp(windowData.location.y, 0, Screen.height - windowData.size.y);

◆ locked

bool GWG.WindowFramework.WindowFrameData.locked

true if the window is locked and cannot be moved or resized by the user; false if the window can be freely manipulated.

When a window is locked, it typically prevents user interactions such as:

  • Dragging to move the window
  • Resizing the window borders
  • Minimizing or maximizing the window
  • Closing the window (depending on implementation)

Locked windows are useful for:

  • Modal dialogs that require user attention
  • HUD elements that should remain in fixed positions
  • System windows that users shouldn't accidentally move
  • Tutorial or onboarding interfaces

The locked state can be changed programmatically even when the window is locked.

// Lock a critical system window
windowData.locked = true;
// Allow user interaction with regular windows
windowData.locked = false;
// Temporarily lock during important operations
windowData.locked = true;
await PerformCriticalOperation();
windowData.locked = false;
// Lock based on window type
if (windowData.windowType == "ModalDialog")
{
windowData.locked = true;
}

◆ lockedToStartPosition

bool GWG.WindowFramework.WindowFrameData.lockedToStartPosition

true if the window should remain locked to its designated start position; false if the window can be moved away from its start position.

This property works in conjunction with windowFrameStartPosition to provide positional constraints. When set to true, it typically:

  • Prevents the window from being moved away from its calculated start position
  • May reset the window position if it gets moved accidentally
  • Ensures critical UI elements remain in expected locations
  • Maintains consistent layouts across different screen configurations

Use Cases:
This is particularly useful for:

  • HUD elements that should always appear in specific screen regions
  • Modal dialogs that should always be centered
  • Tool windows that have optimal positions for workflow
  • Tutorial or onboarding windows with precise positioning requirements
// Lock window to always appear centered
windowData.lockedToStartPosition = true;
windowData.windowFrameStartPosition = WindowFramePosition.Center;
// Allow free positioning for user customization
windowData.lockedToStartPosition = false;
// Lock system critical windows
if (windowData.windowType == "SystemDialog")
{
windowData.lockedToStartPosition = true;
}
// Temporarily unlock for special operations
windowData.lockedToStartPosition = false;
MoveWindowToCustomPosition(windowData);
windowData.lockedToStartPosition = true;
// Conditional locking based on user preferences
windowData.lockedToStartPosition = userSettings.lockWindowPositions;
WindowFramePosition
Enumeration defining predefined positioning options for window frames within the screen space.
Definition WindowFrame.cs:32

◆ name

string GWG.WindowFramework.WindowFrameData.name

A string representing the internal or system name of the window, typically used for identification and debugging purposes.

The name property serves as an internal identifier that differs from the user-visible title. It's commonly used for:

  • Debugging and logging operations
  • Internal window management and lookup
  • Developer tools and window inspection
  • Programmatic window identification

Unlike the title, the name typically remains constant and is not localized or changed based on user preferences.

// Internal names for different window types
windowData.name = "player_inventory_window";
windowData.name = "character_stats_display";
windowData.name = "debug_console_main";
windowData.name = "settings_audio_panel";
// Using name for logging
Debug.Log($"Window '{windowData.name}' is being initialized");

◆ opacity

float GWG.WindowFramework.WindowFrameData.opacity

A float value between 0.0 and 1.0, where 0.0 is completely transparent (invisible) and 1.0 is completely opaque (fully visible).

The opacity property controls the visual transparency of the entire window and its contents. This is useful for:

  • Creating overlay windows that don't fully obstruct background content
  • Implementing fade-in/fade-out animations
  • Providing visual feedback for window states (inactive, disabled, etc.)
  • Creating ghost or preview windows during drag operations

Performance Considerations:
Semi-transparent windows may have performance implications, especially when:

  • Multiple transparent windows overlap
  • Complex content is rendered beneath transparent windows
  • Transparency effects are applied during animations
// Fully opaque window (default)
windowData.opacity = 1.0f;
// Semi-transparent overlay window
windowData.opacity = 0.8f;
// Nearly invisible window for debugging
windowData.opacity = 0.1f;
// Completely transparent (effectively hidden)
windowData.opacity = 0.0f;
// Animate opacity for fade effect
StartCoroutine(FadeWindow(windowData, 0.0f, 1.0f, 2.0f));
// Validate opacity range
windowData.opacity = Mathf.Clamp01(userInputOpacity);

◆ parentObjectId

string GWG.WindowFramework.WindowFrameData.parentObjectId

A string identifier referencing the parent object. Can be null or empty if the window has no parent.

The parent object ID establishes a hierarchical relationship between windows and their containers. This is useful for:

  • Organizing windows into logical groups
  • Managing window lifecycle based on parent state
  • Implementing nested window behaviors
  • Coordinating window operations within a parent context

When a parent object is destroyed or becomes inactive, the window framework can use this information to appropriately handle child windows.

// Window belonging to a specific game object
windowData.parentObjectId = "Player_Character_001";
// Window belonging to a UI panel
windowData.parentObjectId = "SettingsPanel";
// Top-level window with no parent
windowData.parentObjectId = null;
// Window belonging to a scene-specific controller
windowData.parentObjectId = "GameplayUIController";

◆ size

Vector2 GWG.WindowFramework.WindowFrameData.size

A Vector2 representing the window's width (x component) and height (y component) in screen units, typically pixels.

The size property determines the window's dimensions and affects:

  • How much content can be displayed within the window
  • The window's layout and content organization
  • Performance considerations for rendering and UI updates
  • User experience and usability of the window content

Size Constraints:
Consider implementing minimum and maximum size constraints to ensure:

  • Content remains readable and accessible
  • Windows don't become too small to be useful
  • Windows don't exceed screen boundaries
  • Consistent user experience across different screen resolutions
// Standard window size
windowData.size = new Vector2(800, 600);
// Small dialog window
windowData.size = new Vector2(300, 200);
// Full-screen window
windowData.size = new Vector2(Screen.width, Screen.height);
// Square window
windowData.size = new Vector2(400, 400);
// Proportional sizing based on screen resolution
windowData.size = new Vector2(Screen.width * 0.6f, Screen.height * 0.7f);
// Enforce minimum size constraints
var minSize = new Vector2(200, 150);
windowData.size = Vector2.Max(windowData.size, minSize);
// Ensure window fits on screen
windowData.size.x = Mathf.Min(windowData.size.x, Screen.width);
windowData.size.y = Mathf.Min(windowData.size.y, Screen.height);

◆ title

string GWG.WindowFramework.WindowFrameData.title

A string representing the user-visible title displayed in the window's title bar or header.

The title is the text that users see in the window's title bar and is typically:

  • User-friendly and descriptive
  • Localized based on user language preferences
  • Dynamic and may change based on window content or state
  • Used for accessibility and screen reader support

The title can be updated during runtime to reflect changing content or status, such as indicating unsaved changes or current selection.

// Basic window titles
windowData.title = "Player Inventory";
windowData.title = "Game Settings";
windowData.title = "Character Creation";
// Dynamic titles with status information
windowData.title = "Document Editor - Untitled*";
windowData.title = "Chat (3 new messages)";
windowData.title = "Level Editor - Forest_Level_01";
// Localized titles
windowData.title = LocalizationManager.GetText("WINDOW_INVENTORY_TITLE");

◆ visible

bool GWG.WindowFramework.WindowFrameData.visible

true if the window is visible and rendered on screen; false if the window is hidden and not rendered.

The visible property controls whether the window is displayed to the user and affects:

  • Rendering performance (hidden windows may skip rendering)
  • User interaction (hidden windows typically don't receive input)
  • Window management and enumeration operations
  • Memory and resource usage optimization

Visibility vs. Opacity:
Unlike the opacity property, setting visible to false typically:

  • Completely removes the window from rendering pipeline
  • May deallocate rendering resources
  • Prevents all user interaction with the window
  • May affect window layout and positioning of other windows
// Show the window
windowData.visible = true;
// Hide the window
windowData.visible = false;
// Toggle visibility
windowData.visible = !windowData.visible;
// Show window based on game state
windowData.visible = gameState == GameState.InGame;
// Hide all debug windows in release builds
if (!Application.isEditor && windowData.windowType == "DebugWindow")
{
windowData.visible = false;
}
// Show window conditionally
windowData.visible = playerLevel >= requiredLevel;

◆ wasOpen

bool GWG.WindowFramework.WindowFrameData.wasOpen

true if the window was open when the application was last closed; false if the window was closed or never opened in the previous session.

The wasOpen property is used for session persistence and helps the window framework:

  • Restore the exact window state from previous application runs
  • Maintain user workflow continuity between sessions
  • Implement smart window initialization based on usage patterns
  • Provide consistent user experience across application restarts

Usage in Window Restoration:
This property is typically used during application startup to determine which windows should be automatically opened to match the user's previous working environment.

Difference from visible:
While visible represents the current visibility state, wasOpen represents the historical state and is used for persistence logic rather than immediate display control.

// Mark window as having been open in last session
windowData.wasOpen = true;
// During application startup, restore previously open windows
foreach (var windowData in savedWindowStates)
{
if (windowData.wasOpen)
{
CreateAndShowWindow(windowData);
}
}
// Update wasOpen status when window is closed
void OnWindowClosed(WindowFrameData data)
{
data.wasOpen = false;
SaveWindowState(data);
}
// Update wasOpen status when window is opened
void OnWindowOpened(WindowFrameData data)
{
data.wasOpen = true;
SaveWindowState(data);
}
// Restore workspace layout
void RestoreWorkspace()
{
var previouslyOpenWindows = allWindowData.Where(w => w.wasOpen).ToList();
foreach (var window in previouslyOpenWindows)
{
OpenWindow(window.windowId);
}
}

◆ windowFrameStartPosition

WindowFramePosition GWG.WindowFramework.WindowFrameData.windowFrameStartPosition

A WindowFramePosition enumeration value that specifies where the window should initially appear on the screen.

This property defines the initial positioning behavior for the window and is used by the window framework to calculate the appropriate screen coordinates. The start position works in conjunction with lockedToStartPosition to control positioning behavior.

Position Calculation:
The actual screen coordinates are typically calculated based on:

  • Current screen resolution and dimensions
  • Window size (size property)
  • Available screen real estate and system UI elements
  • Multi-monitor configurations and active display

Dynamic Positioning:
Start positions are especially useful for ensuring consistent window placement across:

  • Different screen resolutions
  • Multiple monitor setups
  • Various UI scaling factors
  • Different aspect ratios
// Center the window on screen
windowData.windowFrameStartPosition = WindowFramePosition.Center;
// Position at top-left corner
windowData.windowFrameStartPosition = WindowFramePosition.TopLeft;
// Position at bottom-right corner
windowData.windowFrameStartPosition = WindowFramePosition.BottomRight;
// Set different positions based on window type
switch (windowData.windowType)
{
case "MainWindow":
windowData.windowFrameStartPosition = WindowFramePosition.Center;
break;
case "ToolPalette":
windowData.windowFrameStartPosition = WindowFramePosition.TopLeft;
break;
case "StatusWindow":
windowData.windowFrameStartPosition = WindowFramePosition.BottomRight;
break;
}
// Lock window to its start position for consistency
windowData.windowFrameStartPosition = WindowFramePosition.Center;
windowData.lockedToStartPosition = true;

◆ windowId

string GWG.WindowFramework.WindowFrameData.windowId

A string that uniquely identifies this window frame instance within the application. Should be unique across all window frames to prevent conflicts.

The window ID is used internally by the window framework to manage and reference specific window instances. It should remain consistent across application sessions to ensure proper restoration of window settings.

Best practices for window IDs:

  • Use descriptive names that indicate the window's purpose
  • Include version numbers or timestamps if needed for uniqueness
  • Avoid special characters that might cause serialization issues
// Examples of good window IDs
windowData.windowId = "InventoryWindow";
windowData.windowId = "PlayerStats_v2";
windowData.windowId = "DebugConsole_001";
windowData.windowId = "ChatWindow_" + playerId;

◆ windowType

string GWG.WindowFramework.WindowFrameData.windowType

A string that categorizes the window type, used for applying type-specific behaviors, styling, or management logic.

The window type serves multiple purposes in the window framework:

  • Applying type-specific styling and appearance
  • Determining available window operations and behaviors
  • Grouping windows for management and organizational purposes
  • Implementing type-specific saving and loading logic
  • Enabling type-based window policies and restrictions

Common window types might include dialog boxes, tool windows, document windows, or application-specific categories like inventory, character, or settings windows.

// Common window types
windowData.windowType = "Dialog";
windowData.windowType = "ToolWindow";
windowData.windowType = "DocumentWindow";
windowData.windowType = "ModalDialog";
// Game-specific window types
windowData.windowType = "InventoryWindow";
windowData.windowType = "CharacterSheet";
windowData.windowType = "QuestLog";
windowData.windowType = "MiniMap";
// Using window type for conditional logic
if (windowData.windowType == "Dialog")
{
// Apply dialog-specific behavior
windowData.locked = true;
}