Last active
October 24, 2020 01:03
-
-
Save EliCDavis/798ff505936cc32cec30ffb0321f544b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using RecordAndPlay; | |
using RecordAndPlay.Record; | |
using RecordAndPlay.Playback; | |
using System.Collections; | |
using System.Collections.Generic; | |
using Recolude; | |
namespace Example | |
{ | |
public class ReplayExample : MonoBehaviour | |
{ | |
[SerializeField] | |
private RecoludeConfig config; | |
void Start() | |
{ | |
StartCoroutine(RunPlayback(/*Whatever ID you got from querying Recolude*/)); | |
} | |
private PlaybackBehavior currentPlayback; | |
public IEnumerator RunPlayback(string recordingID) | |
{ | |
var req = config.LoadRecording(recordingID); | |
yield return req.Run(); | |
var recording = req.Recording(); | |
if (recording == null) | |
{ | |
Debug.LogError("Error: " + req.Error()); | |
yield break; | |
} | |
// Stop any previously playing playback | |
if (currentPlayback != null) | |
{ | |
currentPlayback.Stop(); | |
} | |
currentPlayback = PlaybackBehavior.Build(recording, this, this, true); | |
currentPlayback.Play(); | |
} | |
public Actor Build(int subjectId, string subjectName, Dictionary<string, string> metadata) | |
{ | |
return new Actor(GameObject.CreatePrimitive(PrimitiveType.Cube)); | |
} | |
public void OnCustomEvent(SubjectRecording subject, CustomEventCapture customEvent) | |
{ | |
// Do things on custom events from recording | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment