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. You do this in two steps: adding the repository where the Android library is hosted and then adding the dependency itself.

    Where to add the repository and dependency depends on if you are using Unity 2019 or a newer version. In both cases, you will need a file called mainTemplate.gradle.

  5. 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.

    If you are using Unity 2020 or newer:

    Also select the following two options: "Custom Base Gradle Template" and "Custom Base Properties Template". If they don’t already exist, selecting these options will automatically generate baseProjectTemplate.gradle and gradleTemplate.properties, respectively, in the Assets/Plugins/Android directory.

    custom gradle
    Project Settings in Unity 2019
    project settings unity2020
    Project Settings in Unity 2020 or newer

    Once these file(s) are created, open up mainTemplate.gradle.

    If you are using Unity 2019:

    Copy and paste the following line under the repositories section under allprojects.

    maven {
        url 'https://pkgs.dev.azure.com/strivr/SDK/_packaging/StrivrPublicFeed/maven/v1'
    }

    Then copy and paste the following line under the dependencies section. Save the file.

    implementation 'com.strivr.strivr.sdk:strivr.sdk:1.0.22158.03'
    unity 2019 dependencies
    mainTemplate.gradle in Unity 2019

    If you are using Unity 2020 or newer:

    The maven repository goes in baseProjectTemplate.gradle while the dependency goes in mainTemplate.gradle.

    In baseProjectTemplate.gradle, copy and paste the maven repository under both the allprojects/buildscript/repositories and allprojects/repositories sections

    base project template
    baseProjectTemplate.gradle in Unity 2020 or newer

    In mainTemplate.gradle, copy and paste the dependency under dependencies

    main template gradle 2020
    mainTemplate.gradle in Unity 2020 or newer

    If present, remove the following comment at the top of mainTemplate.gradle and/or baseProjectTemplate.gradle:

    // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

    If you are using Unity 2020 or newer:

    Open gradleTemplate.properties and copy and paste the following line under the **ADDITIONAL_PROPERTIES** section. Then, save the file.

    android.useAndroidX=true
    gradle template prop file
    gradleTemplate.properties
    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