private IEnumerator Player() { Recording recording = playerVCR.GetRecording(); if (recording == null) { yield break; } Debug.Log(recording.ToString()); curPlayer = (InputVCR)Instantiate(playbackCharacterPrefab, recordingStartPos, recordingStartRot); curPlayer.Play(Recording.ParseRecording(recording.ToString())); SwapTex(); float playTime = recording.recordingLength; float curTime = 0f; isPlaying = true; while (curTime < playTime) { if (isPlaying) { curTime += Time.deltaTime; } yield return(0); } // Play finished isPlaying = false; Destroy(curPlayer.gameObject); curPlayer = null; SwapTex(); }
private void StartPlay() { if (isPlaying) { // pause curPlayer.Pause(); isPlaying = false; SwapTex(); } else if (curPlayer != null) { // unpause curPlayer.Play(); SwapTex(); isPlaying = true; } else { // try to start new playback if (isRecording) { recordButton.Record(); } StartCoroutine(Player()); } }
private IEnumerator Player() { Recording recording = playerVCR.GetRecording (); if ( recording == null ) yield break; Debug.Log ( recording.ToString () ); curPlayer = (InputVCR)Instantiate ( playbackCharacterPrefab, recordingStartPos, recordingStartRot ); curPlayer.Play ( recording ); SwapTex (); float playTime = recording.recordingLength; float curTime = 0f; isPlaying = true; while ( curTime < playTime ) { if ( isPlaying ) curTime += Time.deltaTime; yield return 0; } // Play finished isPlaying = false; Destroy ( curPlayer.gameObject ); curPlayer = null; SwapTex (); }
/// <summary> /// Starts the replay. /// </summary> public void StartReplay() { //enable scripts GetComponent <Racer>().enabled = true; GetComponent <InputVCR>().enabled = true; transform.GetComponentInChildren <MeshRenderer>().enabled = true; transform.GetComponentInChildren <ParticleSystem>().Play(); //grab the fastest replay and play replay = GameObject.Find("FinishLine").GetComponent <LapController>().fastestRecording; vcr.Play(replay, 0); vcr.finishedPlayback += replayFinished; }