Unity Setup


This tutorial will have you set up and using GameSparks in no time, even with only basic knowledge of the Unity game engine.

First, you'll need to download the GameSparks SDK. This is a Unity-package file, and so importing the SDK into Unity is very simple. You can also download our Unity example below:

Example Unity Setup code can be downloaded here

FAQs? You can review Frequently Asked Questions about working in Unity with GameSparks.

Setting Up the GameSparks SDK

To set up the SDK, follow these steps:

If the package was successfully added to project, you will see that two new folders will have been added to your project called GameSparks and Plugins:


Configuring the GameSparks SDK

Now you have to link your Unity project with your GameSparks game.

If you need instructions on how to create a new GameSparks game through the Portal check out the tutorial here.

In the GameSparks folder that has just appeared in your project, navigate to the Test UI folder, and open the GameSparksTestUI scene. Go ahead and play this scene and see what happens. You will likely see something like this:


There's a couple of important things to note:

Understanding Errors - Unknown Service Error

At this stage, the GameSparks SDK still hasn't been configured or provided with any information on what it should connect to. The error above is telling us that the SDK couldn't connect to the service. When this error occurs, check that your GameSparks details are correct.

Entering API Key and Secret

You now need to provide the SDK details about the game you want to connect to. For the sake of this tutorial, we're connecting to a demo game created on the GameSparks portal.

1. Notice that there's a new tab on the top menu-bar for GameSparks. Select this and click on the Edit Settings option. You'll see GameSparks Settings appear in the Inspector window:


You'll update API Key and API Secret with the key and secret from your game. You can get these from the Game Overview page of the GameSparks portal:


2. Copy both the GameSparks API Key and GameSparks API Secret into the respective fields on the Unity Inspector window:

3. Hit the Test Configuration button and you should see a whole load of info pop up in the dialog box, eventually including a log stating that GameSparks is available.

Congratulations, you are now connected to your GameSparks game!

Still Getting Unknown Service Error?

If you're still seeing the GS: ERROR UNKNOWN SERVICE message:

Other SDK Settings

You can see that there are a few other settings available for the Unity SDK. For the initial setup you don’t need to worry about them, so feel free to skip this part if you are keen to get started:

You are now set up and connected to GameSparks. The next section will show you how to register and authenticate players on your GameSparks game, through the Unity game engine.