Last active
February 10, 2019 18:25
-
-
Save unity3dcollege/80fbe9961489e53c3ea0d9afce172024 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 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