private UniRx.IObservable <Unit> HidePreviousPanel() { return(Observable.Create <Unit>(observer => { if (PreviousPanel.Value == CurrentPanel.Value) { observer.OnCompleted(); return null; } switch (PreviousPanel.Value) { case Panel.MainMenu: LobbyMainMenu.Hide(); break; case Panel.CampaignMenu: CampaignMenu.Hide(); break; case Panel.Lobby: this.lobbyPanel.SetActive(false); break; case Panel.InGame: BattleHUD.Hide(); BattleResultsPanel.Hide(); break; case Panel.LeaderBoards: Leaderboard.Hide(); break; case Panel.ArmyPanel: CardCollectionMenu.Hide(); break; case Panel.ShopPanel: IAPPanel.Hide(); break; case Panel.TasksPanel: TasksMenu.Hide(); break; case Panel.ServerPanel: this.serverPanel.SetActive(false); break; case Panel.SocialPanel: SocialPanel.Hide(); break; case Panel.BattleResultsPanel: BattleResultsPanel.Hide(); break; default: Debug.LogError("Unsupported panel: " + PreviousPanel); break; } observer.OnCompleted(); return null; })); }