Integrate Unity SDK
After you’ve successfully created a game, it’s time to choose what SDK you want to integrate. See the list of all SDKs and how to integrate them here.
For the purpose of this guide, we will integrate the Unity SDK.
The first step is to create a Unity project. Once this is done, the next step is to download the SDK, either from Github or as a Unity package and import it into your newly created project.
To import a package go to Assets > Import Package > Import Package, and navigate to the location on your drive.
Once the project is successfully imported, the next step is to log in to GameAnalytics using the Unity Editor.
Importing the SDK created a GameAnalytics settings object which can be found by opening the Window menu in the editor.
The next step is to login to your GameAnalytics Account using the GameAnalytics settings object by using the same credentials as you use for the website.
Once you are logged in you can choose the Organization, studio and game that you want to connect to Unity. You can do this by using the Add platform button.
In the example below we’ve added the game on the Windows platform:
Game key and secret key are both automatically fetched after you select the game you wish to connect. You can also add a build version for your game.
Next, create the GameAnalytics object by going to Window > GameAnalytics > Create GameAnalytics Object.
After this is successfully set up, the next step is to initialize the SDK. You can do this in any script that runs on runtime, and we suggest putting in the code in the Start method.
For this example project, we’ve created an empty object in the scene called GameAnalytics_controller to which we attached a simple default script.
Inside the script we only added an SDK initialization request, and a dummy design event, to test whether it was initialized correctly.
void start()
{
GameAnalytics.Initialize();
GameAnalytics.NewDesignEvent("Test:DesignEvent:Test", 400);
}
Before testing the events do not forget to build for the respective platform and run the project on that device, as events cannot be tested using the Unity Editor.
Finally, after you built and opened the game, the last step is to see whether or not the integration and initialization of the SDK is successful. To do this navigate to the Realtime feature in the web-tool and see if any data was registered. It should take around 5 minutes for data to be visible in Realtime, after it was sent from the game.
Some suggestions for next steps would be:
- Familiarize yourself with event types
- Create Custom Dashboards
- Familiarize yourself with the Explore Tool