public void TryCloseMenu(UIState targetState, YieldComplete onYieldComplete) { if (State == UIState.BlockInput || targetState == State) { return; } switch (State) { case UIState.SortMenu: SetState(UIState.BlockInput); _sortPanel.Hide(() => { SetState(UIState.Menu); onYieldComplete(); }); return; case UIState.SearchMenu: SetState(UIState.BlockInput); _searchPanel.Hide(() => { SetState(UIState.Menu); onYieldComplete(); }); return; } onYieldComplete(); }