Get SpatialOS

Sites

Menu

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 DefaultMobileWorkerConnector. 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 SpatialOS > GDK Tools configuration 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.

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

  4. Select Save and close the window.

  5. Select SpatialOS > Generate Dev Authentication Token. This generates 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.

    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.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums