# Integrating the Unity Package

If you have an existing Unity app follow these steps to add the .unitypackage. Otherwise, we recommend that you build from the source:

{% content-ref url="building-from-the-source-code" %}
[building-from-the-source-code](https://docs.arway.ai/arway-sdk/building-from-the-source-code)
{% endcontent-ref %}

## **Get the ARwayKit SDK .unitypackage**

Download the .unitypackage from our [GitHub](https://github.com/arway-ai/unity-viewer-sdk/releases). Please [contact us](https://www.arway.ai/contact) for access.

## Prerequisites

In this guide, we will be using the following versions of Unity:

* **Unity:** 2022.3.29f1 LST
  * Include the following platforms in your Unity install:&#x20;
    * Android Build Support&#x20;
      * OpenJDK
      * Android SDK & NDK Tools
    * iOS Build Support

## **Implementation**

In the below instructions, we will be creating a new project in Unity, skip the step for creating a new project if you already have an existing Unity codebase.

### Getting the Account ID and Secret Key

1. From the ARway Creator Portal, go to "For Developers -> Create a New App -> Enter App Name".
2. Copy your **Account ID** and **SecretKey** for that App.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FJu8eWIZGmYcfox7u5qyl%2F9FyMWaoEPl.png?alt=media&#x26;token=81fda761-7ae0-4e6c-824a-85cb6f8c3477" alt=""><figcaption><p>The "For Developers" page of the Creator Portal</p></figcaption></figure>

### **Creating a new project in Unity**

If you have an existing project in Unity, skip this step.

1. Open Unity Hub and click the "New project" button on the top right.&#x20;

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FbJALuRj1KG2Geqppxopv%2Funityhub2.jpg?alt=media&#x26;token=a080d135-54b0-4eaa-98d0-3763cec9276b" alt=""><figcaption><p>Create a new project in Unity hub</p></figcaption></figure>

2. Select the template "3D (Built-In Render Pipeline)" and create your new project (Unity Version **2022.3.29f1**).

   <figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FeDwtF1evtfxFN9C8yOPb%2Fimage.png?alt=media&#x26;token=909501ab-9bba-4747-9b53-04f5dde0621e" alt=""><figcaption><p>Select the 3D (Core) project template. This was renamed from 3D (Core) in the latest version of Unity Hub.</p></figcaption></figure>

   <figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FZc5SAofbtDtwuOiagO7b%2Fimage.png?alt=media&#x26;token=24624ddf-ef7d-4ca1-8065-54f0b294de6d" alt=""><figcaption><p>Select the "3D (Built-In Render Pipeline)" project template. This was changed from "3D" in the latest version of Unity Hub.</p></figcaption></figure>

### **Change Project Platform**

1. Go to "File -> Build Settings..." and select either Android or iOS and then click "Switch Platform".

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FO70KTIQxwb3yhazaM9tC%2Fimage.png?alt=media&#x26;token=f3ce441b-fc83-4e6e-9902-936639455152" alt="" width="488"><figcaption><p>Changing the build settings</p></figcaption></figure>

### **Importing Packages**

1. Go to "Assets -> Import Package -> Custom Package". Then select the ARwayKit SDK **.unitypackage**.
2. In the "Import Unity Package" window import the package.

   <figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2F3coXi6YH4i4HHOI5eU4i%2Fimage.png?alt=media&#x26;token=aa746556-3824-4753-bab0-2668117292c1" alt=""><figcaption><p>Import ARwayKit SDK package in Unity</p></figcaption></figure>
3. Next, the package setup will begin. Click "Install Packages" to install all of the required packages.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FZT8uSRdEAFiAZ4ljIuHs%2Fimage.png?alt=media&#x26;token=20fe1a82-52fe-4e3b-b17b-5b91c70d3033" alt=""><figcaption><p>ARwayKit SDK Setup</p></figcaption></figure>

4. Wait for the packages to install and for the scripts to compile.
5. In the warning pop-up for enabling the backends for the input system package, select either "Yes" or "No" as it is optional for the ARwayKit SDK.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FhWWu5h0cLH2nFPyZDj9O%2Fimage.png?alt=media&#x26;token=13e38c36-8a10-442f-81df-55bbc4046cf3" alt=""><figcaption><p>Choose 'Yes' or 'No' as it is optional for the ARwayKit SDK</p></figcaption></figure>

6. Then click 'Setup SDK' to finish part 2/2 for the setup.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FlLtn93Y0ix7xEoSRomhX%2Fimage.png?alt=media&#x26;token=3eddfa1a-7aed-4fa5-b41a-260b8a874890" alt=""><figcaption><p>Click Setup SDK</p></figcaption></figure>

7. Next, click "import" to import the project settings. Please note that this will overwrite all of your previous project settings.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2F41w9sxQrDdCHXj5a7JuY%2Fimage.png?alt=media&#x26;token=18c62641-0217-4e5d-ac27-ba64e6533f15" alt=""><figcaption><p>Import project settings</p></figcaption></figure>

8. In the Import Unity Package window, select all and click "Next" then "Import".

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FHbxuohZGsb9H1GziSFp6%2Fimage.png?alt=media&#x26;token=e5bcd09c-0dc5-43eb-b8e4-f68a704537ad" alt=""><figcaption><p>Unity Package Window files</p></figcaption></figure>

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FcGfa6KM6Jvvt3BvCFzKf%2Fimage.png?alt=media&#x26;token=41d7eb3d-2a32-4c53-a78b-38d74bb9335b" alt=""><figcaption><p>Unity Package Window settings</p></figcaption></figure>

#### Resolving Issue With No Active LocalizationSettings

{% hint style="info" %}
If after importing the Unity Package you get an error in the console that says "There is no active LocalizationSettings", you can manually resolve this in the Player Settings.  Otherwise, skip to the next step.
{% endhint %}

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FNUMdbEgGO7VT33MoP2va%2Fimage.png?alt=media&#x26;token=0138d341-00d4-4ff3-b69d-d250fdfe85cb" alt=""><figcaption><p>Localization Settings error</p></figcaption></figure>

In the Unity Editor go to "Edit -> Project Settings", the select the "Localization" category on the left. Then if you see beside "Active Settings" the text "None (Localization Settings)" click the button to the right to select the localization settings.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FMNJngIJAVg8EzEnw0MbS%2FScreenshot%202024-06-21%20114012.png?alt=media&#x26;token=2ea1394f-2d32-4421-8619-585c676b1888" alt=""><figcaption><p>Project Settings Localization Settings</p></figcaption></figure>

Then in the new window, Localization Settings Asset. To confirm that it was selected the Available Locales will be shown in the Project Settings window.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FYW4pbBy1I21zfuBQvwVo%2Fimage.png?alt=media&#x26;token=d9f98d3f-f03f-47a7-bcf1-48bb5bf3a1ce" alt=""><figcaption><p>Select Localization Settings</p></figcaption></figure>

Completing these steps will resolve the "There is no active LocalizationSettings" issue.

### Adding the Scenes to the Build

1. Open the Dashboard-SDK scene. Under in the Project tab go to "Assets -> ARWay -> ViewerMode -> 0\_Scene" and double-click Dashboard-SDK.
2. Then open "File -> Build Settings..." and click the "Add Open Scenes" button to add the scene to the build.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FklPEoldeCznpkjQqnwN7%2Fimage.png?alt=media&#x26;token=963d727b-926b-4ea5-b01c-75baf82da12b" alt=""><figcaption><p>Build Settings</p></figcaption></figure>

3. Then do the same for ARMapSession scene "Assets -> ARWay -> ViewerMode -> 0\_Scene" and double-click ARMapSession.
4. Then open "File -> Build Settings..." and click the "Add Open Scenes" button to add the scene to the build.
5. Now both Dashboard-SDK and ARMapSession should be in the "Scenes in Build". Ensure that Dashboard-SDK is the top scene in the build.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FTMJN3aJk9fd9PuBfJgsV%2Fimage.png?alt=media&#x26;token=f64c6718-b428-43a0-bff0-df82c3fd8e20" alt=""><figcaption><p>Build Settings</p></figcaption></figure>

### **Adding the Account ID and Secret Key**

1. In the Project Window, go to "Assets -> ARWay -> ViewerMode -> Resources -> ARWayKitConfig " and add your credentials for the Account ID and Secret Key.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2Fxn5xOqCJf52Nh5Jbf9mI%2Fimage.png?alt=media&#x26;token=09ab9f6e-9399-49db-8bad-d8c8b188be4e" alt=""><figcaption><p>Add credentials in the ARway config file</p></figcaption></figure>

### **Updating the** Addressables Groups

1. Navigate to "Window -> Asset Management -> Addressable -> Groups".
2. In the Addressables Groups window, click on "Build -> New Build -> Default Build Script".

{% hint style="info" %}
When making any changes that affect localization strings, you will need to update the Addressables Groups "Build -> New Build -> Default Build Script".
{% endhint %}

### Building the App

1. In Unity select "File -> Build Settings -> Build -> Select iOS/Android -> Build and Run" to run the app.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2F1dQRSysTb14P1gzU3Rl9%2F16.png?alt=media&#x26;token=0a774f3e-b67a-458d-a69f-fb35108c4e21" alt=""><figcaption><p>Build Settings screen in Unity</p></figcaption></figure>

After successfully building the app on your device, you can scan QR codes that you created for your ARway maps in the Creator Portal.
