Hi Core,
You can simply do the same in your main Scence by defining a function startTimer can call the same from where you want to call like on some button click.
You can refer more Unity Sample available on Git Hub. I am also sharing sample source code how you implement the same.
using UnityEngine;
using System.Collections;
using com.shephertz.app42.paas.sdk.csharp;
using com.shephertz.app42.paas.sdk.csharp.timer;
public class UnitySample : MonoBehaviour, App42CallBack
{
void Start ()
{
string timername = "demo";
string userName = "demo";
App42Log.SetDebug (true);
App42API.Initialize("API_KEY","SECRET_KEY");
}
void OnGUI ()
{
//UI Creation code
}
//Start timer by calling this method
void startTimer(){
TimerService timerService = App42API.BuildTimerService();
timerService.StartTimer(timerName, userName, new UnityCallBack());
}
//Success Callback
public void OnSuccess(object response)
{
Timer timer = (Timer)response;
App42Log.Console("Timer Name is: "+timer.GetName());
App42Log.Console("UserName is:" + timer.GetUserName());
App42Log.Console("Current time is:" + timer.GetCurrentTime());
App42Log.Console("Start time is:" + timer.GetStartTime());
App42Log.Console("End time is:" + timer.GetEndTime());
}
//Exception Callback
public void OnException(Exception e)
{
App42Log.Console("Exception : " + e);
}
}
Let me know if more queries are concern.
Thanks
Vishnu Garg