Question by
daviddickball · Oct 12, 2016 at 07:21 AM ·
javascriptdocumentation
Unity analytics javascript event script not working
So I've added Unity analytics to my project using the built-in stuff in the sidebar, and now want to add an event when a function is called in game. I'm using Javascript, so I've used this code [from the official documentation][1]:
#pragma strict
public class GameLoginMonoBehaviour extends MonoBehaviour {
public function OnGameOver() {
var totalPotions: int = 5;
var totalCoins: int = 100;
Analytics.CustomEvent("gameOver", new Dictionary.<String,Object>());
}
}
However, this immediately gives me an error (I don;t even have to call it), which is: BCE0004: Ambigious reference 'Analytics': UnityEngine.Analytics.Analytics, UnityEngine.Analytics
I'm confused why this doesn't work out of the box as as instructed. [1]: https://docs.unity3d.com/ScriptReference/Analytics.Analytics.CustomEvent.html
Comment