Prepare your project

Create your worker connector script

If you are using one of our Starter Projects, you can skip this section, as you already have one in your project.

If you added the GDK to an existing Unity project rather than using a Starter Project, then you need to create and add a MonoBehaviour script to your mobile client-worker GameObject. To do this:

  1. Create a MonoBehaviour script which inherits from the WorkerConnector. This scripts contains support for both Android and iOS. You can base your implementation on the one in our Blank Starter Project.
  2. In your Unity Editor, add the MonoBehaviour script to your mobile client-worker GameObject.

Create your development authentication token

To connect to a cloud deployment using your mobile device, you need to use the development authentication flow which we provide for the early stages of game development. The GDK for Unity provides tooling around the development authentication flow to help you iterate faster on your mobile application:

  1. Open your project in your Unity Editor.
  2. Navigate to Edit > Project Settings... > Spatial OS to open the configuration window.
  3. In the Dev Auth Token Settings specify the lifetime of the token and the path to the Resources folder that you would like to store the generated token in.

Note: Your token expires after the amount of days that you specified in the configuration window. Regenerate the token whenever that happens:

  1. (for iOS) Ensure that Save token to file is checked.
  2. Select Save and close the window.
  3. Select SpatialOS > Dev Authentication Token > Generate Token. This stores the dev auth token inside the Unity Player Preferences. If Save token to file inside the configuration window is checked, it will also generate a DevAuthToken.txt asset in the folder you specified in the configuration window. This token is used to authenticate when connecting to a cloud deployment.

Note: If your worker connector inherits from the DefaultMobileWorkerConnector script, it will automatically read the content inside DevAuthToken.txt when running the application and authenticate against our services. See the section above to learn how to create a mobile worker connector.

If you want to create your own authentication server, follow this guide.

Updated about a year ago

Prepare your project

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.