Skip to content

Instantly share code, notes, and snippets.

@EliCDavis
Last active October 16, 2020 06:30
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/2baffde1f470f8234e3e907c43472283 to your computer and use it in GitHub Desktop.
Save EliCDavis/2baffde1f470f8234e3e907c43472283 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Recolude;
namespace Example
{
public class ScoreboardBehavior : MonoBehaviour
{
[SerializeField]
RecoludeConfig config;
[SerializeField]
GameObject scoreHolder;
[SerializeField]
GameObject scoreEntryPrefab;
void Start()
{
StartCoroutine(Search());
}
IEnumerator Search()
{
var rs = new RecordingService(config);
var req = rs.ListRecordings(new RecordingService.ListRecordingsRequestParams()
{
// specify this project specifically, because you can actually
// query from multiple projects if you'd like
ProjectId = config.GetProjectID(),
// Order our durations in ascending order, because we want the
// smallest time (fastest) to be presented first.
Order_by = "duration asc",
});
yield return req.Run();
if (req.success != null)
{
foreach (var rec in req.success.recordings)
{
var entryInstance = Instantiate<GameObject>(scoreEntryPrefab, Vector3.zero, Quaternion.identity, scoreHolder.transform);
entryInstance.transform.Find("Text_Timestamp").GetComponent<Text>().text = rec.summary.duration.ToString("N2");
entryInstance.transform.Find("Text_Date").GetComponent<Text>().text = rec.summary.CreatedAt.ToString("MMM d, h:mm tt");
entryInstance.transform.Find("Text_Initials").GetComponent<Text>().text = rec.name;
entryInstance.transform.Find("Button")
.GetComponent<Button>().onClick
.AddListener(() => DoAThing(rec.id));
}
}
else if (req.fallbackResponse != null)
{
Debug.LogError(req.fallbackResponse.message);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment