Created
May 16, 2012 22:37
-
-
Save jakevsrobots/2714586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class PlaytimeTracker : MonoBehaviour { | |
public int heartbeatCount = 0; | |
void Awake() { | |
DontDestroyOnLoad(gameObject); | |
} | |
void Start() { | |
StartCoroutine(PlayTimeHeartbeat()); | |
} | |
IEnumerator PlayTimeHeartbeat() { | |
while(true) { | |
GoogleAnalytics.TrackEventWithValue("play_duration_heartbeat_seconds", "", heartbeatCount * 30); | |
yield return new WaitForSeconds(30); | |
heartbeatCount++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment