Set up the Unity SDK #

This tutorial involves setting up and integrating the Pragma Unity SDK. This includes generating the Pragma SDK sources, integrating it into an Unity project, initializing it, and logging in to the Pragma backend with a test user.

Prerequisites

Confirm correct SDK generation type #

In your pragma-engine/platform/pragma-cli.ini and pragma-engine/platform/pragma-cli-{project-name}.ini files, ensure the sdk type is set to unity:

sdk = unity

Set up the Pragma SDK for Unity #

  1. Copy the update-pragma-sdk.sh file from pragma-engine/sdk/unity into the root directory of your Unity project.

  2. Modify the copied update-pragma-sdk.sh script as follows:

    • Uncomment SOURCE_ENGINE_RELATIVE_FOLDER and change the value to point to your local Pragma Engine repo.

      • eg. SOURCE_ENGINE_RELATIVE_FOLDER="../../pragma-engine"
    • Uncomment TARGET_PRAGMA_SDK_DIR and change the path to "Assets/PragmaSDK".

    Copy update-pragma-sdk.sh into the root directory of your Unity project.

  3. Stop pragma engine if it’s running locally.

  4. Run update-pragma-sdk.sh in Git Bash. Confirm that the files in the Assets/PragmaSDK are updated.

    • Whenever you make changes to Pragma Engine or update the code, you’ll want re-run the update script from your project’s root directory to update the Pragma SDK.

Configure the Pragma SDK #

Create a “Pragma.json” file in your project’s Assets folder and add the following:

{
    "backendAddress": "http://127.0.0.1:10000",
    "gameClientVersion": "DefaultGameClientVersion"
}
Game servers need to connect to the Partner (10100) port over HTTP. These requirements are enforced by the Pragma.Server session object.