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...
|
| 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.
|
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.
{
name =
"Main Application Window",
title =
"My Application v1.0",
size =
new Vector2(800, 600),
};
string json = JsonUtility.ToJson(windowData, true);
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
◆ 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
windowData.location = new Vector2(100, 50);
var screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
var windowCenter = windowData.size / 2f;
windowData.location = screenCenter - windowCenter;
windowData.location = mainWindow.location + new Vector2(50, 30);
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.
windowData.locked = true;
windowData.locked = false;
windowData.locked = true;
await PerformCriticalOperation();
windowData.locked = false;
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
windowData.lockedToStartPosition = true;
windowData.lockedToStartPosition = false;
if (windowData.windowType == "SystemDialog")
{
windowData.lockedToStartPosition = true;
}
windowData.lockedToStartPosition = false;
MoveWindowToCustomPosition(windowData);
windowData.lockedToStartPosition = true;
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.
windowData.name = "player_inventory_window";
windowData.name = "character_stats_display";
windowData.name = "debug_console_main";
windowData.name = "settings_audio_panel";
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
windowData.opacity = 1.0f;
windowData.opacity = 0.8f;
windowData.opacity = 0.1f;
windowData.opacity = 0.0f;
StartCoroutine(FadeWindow(windowData, 0.0f, 1.0f, 2.0f));
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.
windowData.parentObjectId = "Player_Character_001";
windowData.parentObjectId = "SettingsPanel";
windowData.parentObjectId = null;
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
windowData.size = new Vector2(800, 600);
windowData.size = new Vector2(300, 200);
windowData.size = new Vector2(Screen.width, Screen.height);
windowData.size = new Vector2(400, 400);
windowData.size = new Vector2(Screen.width * 0.6f, Screen.height * 0.7f);
var minSize = new Vector2(200, 150);
windowData.size = Vector2.Max(windowData.size, minSize);
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.
windowData.title = "Player Inventory";
windowData.title = "Game Settings";
windowData.title = "Character Creation";
windowData.title = "Document Editor - Untitled*";
windowData.title = "Chat (3 new messages)";
windowData.title = "Level Editor - Forest_Level_01";
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
windowData.visible = true;
windowData.visible = false;
windowData.visible = !windowData.visible;
windowData.visible = gameState == GameState.InGame;
if (!Application.isEditor && windowData.windowType == "DebugWindow")
{
windowData.visible = false;
}
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.
windowData.wasOpen = true;
foreach (var windowData in savedWindowStates)
{
if (windowData.wasOpen)
{
CreateAndShowWindow(windowData);
}
}
void OnWindowClosed(WindowFrameData data)
{
data.wasOpen = false;
SaveWindowState(data);
}
void OnWindowOpened(WindowFrameData data)
{
data.wasOpen = true;
SaveWindowState(data);
}
void RestoreWorkspace()
{
var previouslyOpenWindows = allWindowData.Where(w => w.wasOpen).ToList();
foreach (var window in previouslyOpenWindows)
{
OpenWindow(window.windowId);
}
}
◆ 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
switch (windowData.windowType)
{
case "MainWindow":
break;
case "ToolPalette":
break;
case "StatusWindow":
break;
}
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
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.
windowData.windowType = "Dialog";
windowData.windowType = "ToolWindow";
windowData.windowType = "DocumentWindow";
windowData.windowType = "ModalDialog";
windowData.windowType = "InventoryWindow";
windowData.windowType = "CharacterSheet";
windowData.windowType = "QuestLog";
windowData.windowType = "MiniMap";
if (windowData.windowType == "Dialog")
{
windowData.locked = true;
}