void Update() { if (Input.GetKeyUp(SkipShortcut)) { singSceneController.SkipToNextSingableNote(); } if (Input.GetKeyUp(OpenInEditorShortcut)) { singSceneController.OpenSongInEditor(); } if (Input.GetKeyUp(RestartShortcut)) { singSceneController.Restart(); } if (Input.GetKeyUp(BackToSongSelectShortcut) || Input.GetKeyUp(BackToSongSelectShortcut2)) { singSceneController.FinishScene(false); } if (Input.GetKeyUp(PauseShortcut)) { singSceneController.TogglePlayPause(); } }
private void Start() { InputManager.GetInputAction(R.InputActions.usplay_skipToNextLyrics).PerformedAsObservable() .Subscribe(_ => singSceneController.SkipToNextSingableNote()); InputManager.GetInputAction(R.InputActions.ui_navigate).PerformedAsObservable() .Where(context => context.ReadValue <Vector2>().x > 0) .Subscribe(_ => singSceneController.SkipToNextSingableNote()); InputManager.GetInputAction(R.InputActions.usplay_openSongEditor).PerformedAsObservable() .Subscribe(_ => singSceneController.OpenSongInEditor()); InputManager.GetInputAction(R.InputActions.usplay_restartSong).PerformedAsObservable() .Subscribe(_ => singSceneController.Restart()); InputManager.GetInputAction(R.InputActions.usplay_togglePause).PerformedAsObservable() .Subscribe(_ => singSceneController.TogglePlayPause()); InputManager.GetInputAction(R.InputActions.usplay_back).PerformedAsObservable() .Subscribe(_ => { if (!songAudioPlayer.IsPlaying) { singSceneController.TogglePlayPause(); } else { singSceneController.FinishScene(false); } }); InputManager.AdditionalInputActionInfos.Add(new InputActionInfo("Skip To Next Lyrics", "Navigate Right")); InputManager.AdditionalInputActionInfos.Add(new InputActionInfo("Toggle Pause", "Double Click")); }
protected override void FillContextMenu(ContextMenu contextMenu) { contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_togglePause), () => singSceneController.TogglePlayPause()); contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_restart), () => singSceneController.Restart()); contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_skipToNextLyrics), () => singSceneController.SkipToNextSingableNote()); contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_exitSong), () => singSceneController.FinishScene(false)); contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_openSongEditor), () => singSceneController.OpenSongInEditor()); }
void Update() { double durationOfSongInMillis = singSceneController.DurationOfSongInMillis; if (durationOfSongInMillis <= 0) { return; } if (isSongFinished) { durationAfterSongFinishedInSeconds += Time.deltaTime; if (durationAfterSongFinishedInSeconds >= 1) { singSceneController.FinishScene(); } } else { double positionInSongInMillis = singSceneController.PositionInSongInMillis; // Normal detection of song finished. // This only works when the position is not reset to zero when the AudioClip finishes. if (Math.Abs(durationOfSongInMillis - positionInSongInMillis) <= 1) { isSongFinished = true; } // Detection of the end of the song by looking for a falling flank in the position in the song. if (hasBeenNearEndOfSong) { // The position is back to the start. if (positionInSongInMillis < 1000 && positionInSongInMillis < positionInSongInMillisOld) { isSongFinished = true; } positionInSongInMillisOld = positionInSongInMillis; } else { // The position is near the end of the song. double missingMillis = durationOfSongInMillis - positionInSongInMillis; if (missingMillis < 1000) { hasBeenNearEndOfSong = true; } } } }