Elements

WindowManager

Owns a collection of Window instances, handles their lifecycle (creation, persistence, disposal), z-order, and placement. Use one WindowManager per panel/viewport. Windows are obtained via the GetWindow<T>(id) factory, which returns the existing instance on subsequent calls (singleton-per-(type, id)).

Position and size are persisted to PlayerPrefs under a configurable prefix. A separate index key tracks all stored window ids so ClearAllStoredPlacements() can remove them without scanning all of PlayerPrefs.

Constructor

var manager = new WindowManager();
parent.Add(manager.BuildVisualElement());

Examples

Single manager, multiple windows

var manager = new WindowManager();
rootPanel.Add(manager.BuildVisualElement());

manager.GetWindow<InventoryWindow>();          // id defaults to "Common"
manager.GetWindow<ChatWindow>("guild");
manager.GetWindow<ChatWindow>("party");        // distinct second instance of ChatWindow

Custom preference prefix (per-save-slot windows)

var manager = new WindowManager { PreferenceKeyPrefix = $"Save{slotId}.Window" };

Reset all stored placements

manager.ClearAllStoredPlacements();   // clears persisted positions/sizes; existing windows are not closed

Programmatic close

var inventory = manager.GetWindow<InventoryWindow>();
inventory.Close();

Properties

PropTypeDefault
PreferenceKeyPrefix?
string
"ELEMENTS.Window"

Methods

PropTypeDefault
GetWindow?
<T>(string id = "Common") where T : Window, new() => T
-
ClearStoredPlacement?
(string fullId) => void
-
ClearAllStoredPlacements?
() => void
-
Dispose?
() => void
-

CSS Classes

  • .elements-window-manager — Manager root (an absolutely-positioned container that fills its parent).

WindowManager extends Component.