# Guide to migrate a GVR project to Cardboard.

This guide shows you how to migrate Unity projects from the
deprecated Google VR (GVR) to use the Cardboard XR Plugin.

> [!NOTE]
> **Note:** To demonstrate the migration, you'll use **HelloVR** , a demo game provided by the [Google VR SDK for Unity](https://github.com/googlevr/gvr-unity-sdk/releases), to directly visualize the changes and adaptations needed. Configurations for other application scenes may vary based on their specific requirements and functionalities.

## Set up your development environment

Software Requirements:

- [Unity 2021.3.32f1](https://unity3d.com/get-unity/download/archive) or later supported by the Cardboard XR Plugin.
  - Make sure to include Android and iOS Build Support during installation.

## Open your GVR project and export the scene without the GVR package.

Follow these steps to open your existing GVR project and export the scene.

1. Open your Unity project using GVR.

2. In Unity, go to **Assets** \> **Export package** to export the current project.

   ![Alt text](https://developers.google.com/static/cardboard/develop/unity/images/export_package.png "Export package")
3. Unselect all folders containing scripts to avoid compiling errors when
   importing the project on a newer version of Unity, as it does not support GVR.

   ![Alt text](https://developers.google.com/static/cardboard/develop/unity/images/exporting_package.png "Exporting package")

## Create a new project on a newer version of Unity and import your project.

1. Open a newer version of Unity supported by Cardboard XR Plugin (Unity 2021.3.32f1 or later) and create a new **3D** project.
2. Import the GVR project.

   ![Alt text](https://developers.google.com/static/cardboard/develop/unity/images/import_package.png "Import package")

## Import the Cardboard SDK.

1. Import the Cardboard SDK following the [Quickstart for Google Cardboard for Unity](https://developers.google.com/cardboard/develop/unity/quickstart#import_the_sdk_and_create_a_new_project).

## Adjust the scene settings to be supported by Cardboard.

> [!NOTE]
> **Note:** The following steps are necessary specifically for the **HelloVR** sample to function as intended. This section might differ when configuring other applications.

1. Add the **ObjectController** script to all interactive objects in the scene.

   1. On the Hierarchy panel navigate to Treasure and select the Icosahedron shape

      ![Alt text](https://developers.google.com/static/cardboard/develop/unity/images/treasure.png "Treasure")
   2. On the Inspector panel on the left, in the Script component, select the ObjectController script.

      ![Alt text](https://developers.google.com/static/cardboard/develop/unity/images/object_controller.png "ObjectController script")
   3. Repeat the process on all three shapes.

2. Drag the script **CardboardReticlePointer.cs** to **Player** \> **Main Camera** \> **GVRReticlePointer**.

   The script is located at
   `Packages/com.google.xr.cardboard/Runtime/CardboardReticlePointer.cs`.

   ![Alt text](https://developers.google.com/static/cardboard/develop/unity/images/cardboard_reticle_pointer.png "CarboardReticlePointer script")
3. Drag the script **CardboardStartup.cs** to the **CubeRoom**.

   The script is located at
   `Assets/Samples/Google Cardboard XR Plugin for Unity/<version>/
   Hello Cardboard/Scripts/CardboardStartup.cs`.

   ![Alt text](https://developers.google.com/static/cardboard/develop/unity/images/cardboard_startup.png "CardboardStartup script")
4. Select **Player** \> **Main Camera** and, in the Inspector panel, add the component **Tracked Pose Driver**.

   ![Alt text](https://developers.google.com/static/cardboard/develop/unity/images/tracked_pose_driver.png "Tracked Pose Driver component")

## Configure and build your project.

1. Follow the configuration guide provided in the [Quickstart for Google Cardboard for Unity](https://developers.google.com/cardboard/develop/unity/quickstart#configuring_android_project_settings) for your respective device.