Create a gist now

Instantly share code, notes, and snippets.

Embed
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Analytics;
public class MyGameNameHereAnalytics : MonoBehaviour
{
private void Start()
{
DontDestroyOnLoad(this.gameObject);
LevelController.OnLevelComplete += LevelController_OnLevelComplete;
PlayerController.OnPlayerDied += PlayerController_OnPlayerDied;
}
private void PlayerController_OnPlayerDied(Vector3 deathPosition, IEnemy killedBy)
{
Dictionary<string, object> data = new Dictionary<string, object>();
data.Add("Position", deathPosition);
data.Add("KilledBy", killedBy.Name);
Analytics.CustomEvent("PLAYER_DIED", data);
}
private void LevelController_OnLevelComplete(string levelName)
{
Analytics.CustomEvent("LEVEL_COMPLETE:" + levelName);
}
private void OnDestroy()
{
Analytics.FlushEvents();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment