diff --git a/Content.Client/GameObjects/Components/Actor/CharacterInterface.cs b/Content.Client/GameObjects/Components/Actor/CharacterInterface.cs index 789d428a03..816dd89f37 100644 --- a/Content.Client/GameObjects/Components/Actor/CharacterInterface.cs +++ b/Content.Client/GameObjects/Components/Actor/CharacterInterface.cs @@ -36,6 +36,8 @@ namespace Content.Client.GameObjects.Components.Actor /// public SS14Window Window { get; private set; } + private List _uiComponents; + /// /// Create the window with all character UIs and bind it to a keypress /// @@ -44,13 +46,13 @@ namespace Content.Client.GameObjects.Components.Actor base.Initialize(); //Use all the character ui interfaced components to create the character window - var uiComponents = Owner.GetAllComponents().ToList(); - if (uiComponents.Count == 0) + _uiComponents = Owner.GetAllComponents().ToList(); + if (_uiComponents.Count == 0) { return; } - Window = new CharacterWindow(uiComponents); + Window = new CharacterWindow(_uiComponents); Window.OnClose += () => _gameHud.CharacterButtonDown = false; } @@ -61,7 +63,15 @@ namespace Content.Client.GameObjects.Components.Actor { base.OnRemove(); - Window?.Dispose(); + foreach (var component in _uiComponents) + { + // Make sure these don't get deleted when the window is disposed. + component.Scene.Orphan(); + } + + _uiComponents = null; + + Window?.Close(); Window = null; var inputMgr = IoCManager.Resolve();