Skip to content

Instantly share code, notes, and snippets.

@EliCDavis
Last active October 24, 2020 01:04
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/7723f050cdb35cd749b4ef663bc21b9e to your computer and use it in GitHub Desktop.
Save EliCDavis/7723f050cdb35cd749b4ef663bc21b9e to your computer and use it in GitHub Desktop.
Example of how to upload a recording to recolude
using UnityEngine;
using Recolude;
using RecordAndPlay;
using RecordAndPlay.Record;
using System.Collections;
namespace Example
{
public class UploadExample : MonoBehaviour
{
[SerializeField]
private RecoludeConfig config;
[SerializeField]
private GameObject[] objectsToRecord;
private Recorder recorder;
void Awake()
{
// Create a recorder
recorder = ScriptableObject.CreateInstance<Recorder>();
// Attach all objects with a recorder
foreach (var obj in objectsToRecord)
{
SubjectBehavior.Build(obj, recorder);
}
}
// Start is called before the first frame update
void Start()
{
recorder.Start();
StartCoroutine(WatchForCompletion());
}
IEnumerator WatchForCompletion()
{
Recording myRecording = null;
while (recorder.CurrentlyRecording())
{
yield return new WaitForEndOfFrame();
var allDead = true;
foreach (var obj in objectsToRecord)
{
if (obj != null)
{
allDead = false;
}
}
if (allDead)
{
myRecording = recorder.Finish();
}
}
var req = config.BuildUploadRecordingRequest(myRecording);
yield return req.SendWebRequest();
Debug.Log("Recording uploaded!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment