Setting Up the GameSparks SDK

Once you have a Unity project set up and ready, select the Assets tab from the top menu-bar.

From the drop-down menu, select Import Package and then Custom Package from the menu that appears.

This causes an explorer window to appear. From here you can navigate to where your SDK-package was downloaded. When Unity prompts you to import the package file, make sure all files are selected and click Import.

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:

You can see a dialog box and some buttons indicating different requests on the left.

You can see that you get an error here GS: ERROR: UNKNOWN SERVICE.

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:

You can click Copy next to the API Key field.

The API Secret is hidden by default, but you can click on the field or click Show to reveal the secret and then use Copy.

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:

Double-check that there are no trailing or preceding spaces in the API Key and API Secret fields.

Please check that the code you entered in the GameSparks Settings did not contain space characters.

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:

Credential - Specify the Credential you want to use when connecting to the GameSparks platform. You might want to use a custom Credential you've created for your game's players and to check the permissions set defined by that custom Credential. See the Credentials page for more details on creating and configuring Credentials.

Preview Build - This allows you to connect the SDK to preview builds of your game.