public void SwitchTo <T>(Func <T> genNewElement) where T : Element { var oldElement = _uiSystem.Get(SWITCH_ELEMENT_NAME)?.Element; if (oldElement is not null) { _uiSystem.Remove(SWITCH_ELEMENT_NAME); } if (oldElement is null || oldElement is not T) { _uiSystem.Add(SWITCH_ELEMENT_NAME, genNewElement()); } }