Set Up the Unity SDK #

In this section, we’ll be generating a Unity SDK package, importing it into our project, and completing the initial configuration.


Prepare the setup script #

Create a new project (optional)
  1. Open the Unity Hub application.
  2. When Unity Hub opens, click the New Project button.
  3. In the New project view:
    • Select the version of Unity you wish to use.
    • Select the appropriate template for your game.
    • Name your project.
    • Choose the save location for your project.
    • Click the “Create project” button to get started.

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

  1. Open update-pragma-sdk.sh and modify it as follows:
  • Uncomment SOURCE_ENGINE_GITHUB_REPO.
  • Change the value of SOURCE_ENGINE_GITHUB_REPO to point to your Pragma Engine repo.
  • Uncomment TARGET_PRAGMA_SDK_DIR.
  • Change the path to "Assets/PragmaSDK".

  1. Run update-pragma-sdk.sh in Git Bash. Confirm that the PragmaSDK folder now exists in your Assets directory.

  2. Open your Unity project in Unity Editor.

  3. Create a “Pragma.json” file in your project’s Assets folder using File Explorer.

  4. Replace the contents of Pragma.json and save. It should appear at the bottom of the Unity window in the project area:

    {
        "backendAddress": "http://127.0.0.1:10000",
        "protocolType": "WebSocket",
        "gameClientVersion": 1
    }
    
    Game servers need to connect to the Partner (10100) port over HTTP. These requirements are enforced by the Pragma.Server session object.
  5. From the File menu, choose Build Settings…, then click the Player Settings button.

  6. Expand Other Settings, then scroll to the Script Compilation section. Under Scripting Define Symbols click the + button and add PRAGMA_LOG_VERBOSE, then click Apply. This enables full payload logging of all messages to and from the engine.

Additional setup is required for Unity 2022.1 and newer. Please see the following directions.
Unity 2022 setup
  1. Reopen the Player Settings window if necessary.
  2. In the Other Settings section, scroll to the Configuration section. In the Allow downloads over HTTP* dropdown, select Allowed in development builds.