Getting Started

To get started, import the Strivr SDK Unity Package into your project via UPM (Unity Package Manager).

NOTE: The minimum supported Unity version is 2019.1.x and Android is the only supported platform. The minimum supported Android version is Android 4.1, "Jelly Bean", API level 16. For testing/debugging purposes, you can use Debug Mode to log events to the console on any platform.
  1. In Unity, go to Window → Package Manager

    package manager
  2. In the window that pops up, click the plus (+) icon in the status bar.

  3. Click Add package from disk…​ to bring up a file browser

    add package
  4. Navigate to the root of the com.strivr.strivrsdk folder that you downloaded.

  5. Open the package.json file in the root folder.

    package file

Project Setup

Once the package is installed, you must first link your project before you can start tracking data.

  1. In Unity, go to Strivr → Settings

    strivr settings
  2. In the window that pops up, you will see three fields that you need to fill out: Developer Tenant Id, Project Id, and API Key.

    strivr project settings

    For each of the three fields, copy and paste the values that you received from Strivr. If you have any questions regarding this step, contact justin.cellona@strivr.com.

  3. Once you fill out the three fields, click Link Account.

  4. After your project is linked, you need to add Android dependencies to your project.

    If you do not already have a file called mainTemplate.gradle in your project, you can create one by going to Edit → Project Settings…

    unity project settings

    Then, under Player → Android tab → Publishing Settings → Build, select the option that says "Custom Gradle Template" or "Custom Main Gradle Template". If it doesn’t already exist, this will automatically generate the mainTemplate.gradle file in the Assets/Plugins/Android directory.

    custom gradle
  5. Once this file is created, open it and copy and paste the following lines under the dependencies section. Then save the file.

    implementation 'androidx.work:work-runtime:2.7.1'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    gradle file

    If present, remove the following comment at the top of the file:

    // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
  6. If you are using Unity 2020 or newer, you will have to explicitly enable AndroidX in your gradleTemplate.properties file. In the same window under Player → Android tab → Publishing Settings → Build, select the option that says "Custom Gradle Properties Template". If it doesn’t already exist, this will automatically generate the gradleTemplate.properties file in the Assets/Plugins/Android directory.

    gradle properties
  7. Once this file is created, open it and copy and paste the following line under the **ADDITIONAL_PROPERTIES** section. Then, save the file.

    android.useAndroidX=true
    gradle template prop file
    Important: The StrivrSDK prefab needs to be placed in the first scene of the build only. The prefab has a DontDestroyOnLoad script on it, so the prefab will persist throughout scene progressions. If there were already scenes added to the Build Settings upon integration of the plugin, the prefab will already be in the first scene and the popup window will have alerted you which scene the prefab was placed into when you linked your account. If you have not yet set up the scenes in Build Settings, you will need to manually add the prefab to the proper scene. You can find the prefab in Packages → Strivr SDK → Runtime → Prefabs. Drag the StrivrSDK prefab into what will be the first scene in the build