Customizing events through code

It's great to have a way to do the events through the editor, but for those who are more comfortable working with code, it's also just as easy to do so.

One additional thing that we may want to track is how far players get before they lose. Let's take a look at how to do that now:

  1. First, we will need to open up the ObstacleBehaviour script to modify what happens when the game ends.
  2. To utilize Unity Analytics at the top of the file, we will add the following using declarations:
using UnityEngine.Analytics; // Analyticsusing System.Collections.Generic; // Dictionary

The top option is obvious, but we are also adding System.Collections.Generic in order to get access to the Dictionary class, which we will use ...

Get Unity 2017 Mobile Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.