void Start() { // Toggle Search InputManager.GetInputAction(R.InputActions.usplay_toggleSearch).PerformedAsObservable() .Subscribe(_ => ToggleSearch()); // Toggle song is favorite InputManager.GetInputAction(R.InputActions.usplay_toggleFavorite).PerformedAsObservable() .Subscribe(_ => songSelectSceneController.ToggleSelectedSongIsFavorite()); // Toggle favorite playlist is active InputManager.GetInputAction(R.InputActions.usplay_toggleFavoritePlaylistActive).StartedAsObservable() .Subscribe(_ => songSelectSceneController.ToggleFavoritePlaylist()); // Close search or leave scene with Back InputManager.GetInputAction(R.InputActions.usplay_back).PerformedAsObservable() .Subscribe(_ => OnBack()); // Select random song InputManager.GetInputAction(R.InputActions.usplay_randomSong).PerformedAsObservable() .Subscribe(_ => songSelectSceneController.OnRandomSong()); // Open the song editor InputManager.GetInputAction(R.InputActions.usplay_openSongEditor).PerformedAsObservable() .Subscribe(_ => songSelectSceneController.StartSongEditorScene()); // Toggle selected players InputManager.GetInputAction(R.InputActions.usplay_togglePlayers).PerformedAsObservable() .Subscribe(_ => songSelectSceneController.ToggleSelectedPlayers()); // Open the sing scene InputManager.GetInputAction(R.InputActions.ui_submit).PerformedAsObservable() .Subscribe(OnSubmit); InputManager.GetInputAction(R.InputActions.usplay_start).PerformedAsObservable() .Subscribe(_ => songSelectSceneController.CheckAudioAndStartSingScene()); // Select next / previous song with (hold) arrow keys or mouse wheel InputManager.GetInputAction(R.InputActions.ui_navigate).PerformedAsObservable() .Subscribe(OnNavigate); InputManager.GetInputAction(R.InputActions.ui_scrollWheel).PerformedAsObservable() .Subscribe(OnScrollWheel); }
void Update() { EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier(); // Open / close search via Ctrl if (Input.GetKeyDown(KeyCode.LeftControl)) { if (songSelectSceneController.IsSearchEnabled()) { songSelectSceneController.DisableSearch(); } else { songSelectSceneController.EnableSearch(SearchInputField.ESearchMode.ByTitleOrArtist); } } // Fuzzy search. Do not handle other input in this case. if (IsFuzzySearchActive()) { UpdateFuzzySearchInput(); return; } if (modifier != EKeyboardModifier.None) { return; } if (songSelectSceneController.IsSearchEnabled()) { // Close search via Escape or Return / Enter if (Input.GetKeyUp(KeyCode.Escape) || (Input.GetKeyUp(KeyCode.Return) && songSelectSceneController.IsSearchTextInputHasFocus())) { songSelectSceneController.DisableSearch(); } } else { // Open the main menu via Escape or Backspace if (Input.GetKeyUp(KeyCode.Escape) || Input.GetKeyUp(KeyCode.Backspace)) { SceneNavigator.Instance.LoadScene(EScene.MainScene); } // Random song select via R if (Input.GetKeyUp(KeyCode.R) && IsNoControlOrSongButtonFocused()) { songSelectSceneController.OnRandomSong(); } // Open the song editor via E if (Input.GetKeyUp(KeyCode.E) && IsNoControlOrSongButtonFocused()) { songSelectSceneController.StartSongEditorScene(); } } // Select next / previous song with arrow keys or mouse wheel if (Input.GetKeyUp(KeyCode.RightArrow) || Input.mouseScrollDelta.y > 0) { songSelectSceneController.OnNextSong(); } if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.mouseScrollDelta.y < 0) { songSelectSceneController.OnPreviousSong(); } // Open the sing scene via Return / Enter if (Input.GetKeyUp(KeyCode.Return) && IsNoControlOrSongButtonFocused()) { songSelectSceneController.StartSingScene(); } // Toggle active players with Tab if (Input.GetKeyUp(KeyCode.Tab)) { songSelectSceneController.ToggleSelectedPlayers(); } }