/// <summary> /// Removes the UI Element. /// </summary> public void RemoveUIElement(UIElement uiElement) { UIElements.Remove(uiElement); if (uiElement is IInteractable interactable) { Interactables.Remove(interactable); //Deactivate forced focus: if (ForceFocusedInteractable == interactable) { ForceFocusOn = false; ForceFocusedInteractable = null; } //Unselect it from the "keyboard": if (kb_selectedInteractable == interactable) { kb_selectedInteractable = null; } //Unselect it from the "mouse": if (ms_selectedInteractable == interactable) { ms_selectedInteractable = null; } } if (uiElement is IScrollable scrollable) { Scrollables.Remove(scrollable); } if (uiElement is IContainer container) { foreach (UIElement child in container.Children) { RemoveUIElement(child); } } uiElement.OnDestroy(); }