Quick Start

Good to know: The YUR Watch 3D model itself is loaded at runtime and is not visible in the editor when not in Playmode. If you wish to configure the watches themselves, you can visit their prefabs under YUR.SDK>YUR.Watch>Watches.

Make your first request

Create a new script and paste this snippet into the class you created:

using YUR.Fit.Unity;
using static YUR.Fit.Unity.CoreServiceManager;
using YUR.Fit.Core.Models;

public class YUR_ServiceManager : MonoBehaviour
{
	private void Awake() 
	{
		// Magic line that makes the YUR service run
		CoreServiceManager.RunServices
		(
		    OnOverlayUpdate: OnStatusUpdate, /* Fires action every second */
		    OnServiceShutdown: OnServiceShutdown
		);
	}
	
	// This is used to update objects that use the YUR workout metrics
	private void OnStatusUpdate(OverlayStatusUpdate obj)
	{
	    Debug.Log
	    (
	    "Latest Status Update: "
			+ "\n" + "Game Name: " + obj.GameName
	    + "\n" + "Est Heart Rate: " + obj.CalculationMetrics.EstHeartRate
	    + "\n" + "Squat Count: " + obj.SquatCount
	    + "\n" + "Current Calories: " + obj.CurrentCalories.ToString("F2")
	    + "\n" + "Today's Calories: " + obj.TodayCalories
	    );
	}
	
	// Used to notify the developer that the service is shutting down
	private void OnServiceShutdown(ExecutionResult obj)
	{
	    Debug.Log("Shutting Down...");
	}
}

Take a look at what you might call to authenticate a user with YUR, a Shortcode (six-digit) login (this is the preferred method of login for privacy reasons).

CoreServiceManager.ShortcodeLogin
(
	OnLoginRequest, //Action<>
	OnLoginResponseSuccess, //Action
	OnLoginResponseFailure //Action<string>
);

// Add listeners to this in order to get a 
// PIN to log in with on https://app.yur.fit/code or yur.watch
private void OnLoginRequest(YURShortcodeResponse obj)
{
    Debug.Log("Shortcode: " + obj.ShortCode);
		Debug.Log("Verification URL: " + obj.VerificationURL);
}

// Fired if able to log in
private void OnLoginResponseSuccess()
{
    Instance.Log("YUR Logged In!");
}

// Fired if user cannot retrieve PIN or otherwise could not log in
private void OnLoginResponseFailure(string obj)
{
    Instance.Log("YUR Login Failed! Error: " + obj);
}

Last updated