Skip to content

Instantly share code, notes, and snippets.

@EliCDavis
Last active October 24, 2020 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EliCDavis/798ff505936cc32cec30ffb0321f544b to your computer and use it in GitHub Desktop.
Save EliCDavis/798ff505936cc32cec30ffb0321f544b to your computer and use it in GitHub Desktop.
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