Working with the same assets on a Unity VR game across multiple devices

Memo Khoury
WeAreStudios
Published in
6 min readSep 14, 2020

--

Hey guys! This is our first WeAre blog post ever and it is exciting! We do hope you enjoy it and if you have any questions or comments, let us know in the comments.

So, on to the butter! We are ready to show the world the wonders of your creations with exciting VR games, apps or experiences. It’s exciting, hell yes! But, as our project ascends, we find that our assets under development are growing and our project size is getting bigger. Hmm, well that shouldn’t pose a problem as long as our PC can handle it, right?

Of course! But the question we should be asking yourself is: what if we wanted to modify any of the assets that are used in the scene(s) … anywhere? That’s right, we cannot just pick up our workstation and move anywhere … unless we’re superheroes. Like the Hulk. But we’re not! So what can we do?

If we already own a decent laptop, technically we can modify the assets from the same project everywhere … except our laptops most likely can’t handle the VR experience/game project. What we can do, however, is modify the assets efficiently in a separate Unity project on our laptop (so long as our laptop can run it).

How? Let’s dive in!

Below is an example of some terrain data we’re using for a WeAre video game. Let’s call it data_doom_mountain.

Above, we see many different folders in the Assets directory. They are a little bit over around 8GB of content. Plus, the critical ones can only work properly with an Oculus Rift connected to the Unity project. No good for our on-the-go laptop. So, what if we just wanted to modify the terrain data in the level? We definitely don’t need a VR headset to do that!

We need to create a folder that shares the assets (in this case, data_doom_mountain) with the VR Unity project of our PC and with a separate Unity project on our tablets/laptops.

The following .gif demonstrates the ability for us to modify the same asset(s) on a different device (in this case a Surface Pro). This asset was modified away from our work station.

Modifying data_doom_mountain with a Surface stylus is fun!

After we are done modifying, we can check out what it looks like in our VR project on our PC.

data_doom_mountain is looking fantastic!

Ta-da! Cool, right? Since both the Unity VR project on our PC and the Unity project on our Surface share the same Assets directory, we get the same terrain data on data_doom_mountain when we reload our VR Unity project.

So, what are we waiting for? Let’s create this assets pipeline!

Creating an assets pipeline

Step 1

Let us begin with creating this assets pipeline! For this example we are going to begin by creating a new Unity project called SampleAssetsPipelineProject that is configurable with VR. It would be a wise choice if we gave this role to our VR-ready PC, the producer. If you already have a VR project configured, you can skip this step. If you are a beginner, then check out the Unity docs on VR. The VR front-end SDK we will use is the SteamVR Unity plugin. Check out their documentation if you are interested!

Step 2

In the Assets directory, we create a new folder for storing our assets in the cloud. In this example, we use a GitHub repository. Therefore, we will name our new folder GitHub.

Step 3

Now, we head over to GitHub and create a new repository. This is the repository that will be shared between our devices. We can use whatever version control based product we need to use, so GitHub is cool.

Step 4

Copy the repository’s link after creating it, and open GitBash. Make sure you have the Git command line package installed. cd into your GitHub folder you created in the SampleAssetsPipelineProject and run the following command:

git clone <link-of-our-sample-assets-pipeline-directory-repo>

This will clone the SampleAssetsPipelineDirectory directory into our VR Project.

Step 5

Head on to Unity and open let’s open SampleAssetsPipelineDirectory .

Step 6

For this example, I’d like to test having different objects on a specific table. When I add a new 3D Object into the repository from my surface, I’d like it to appear on my table. This is what our table looks like but you can make whatever you want!

To create our table, we add 3D Object > Cube and scale it to x: 0.3 y: 1 z: 2 .

Step 7

After creating our table, let’s name it Table of Accessories.

Next, create a new folder in the SampleAssetsPipelineDirectory and call it Prefabs. Drag the Table of Accesories asset from the scene and into the Prefabs folder.

Step 8

Head back to GitBash and run the following commands (make sure you are in the root folder of SampleAssetsPipelineDirectory).

git add .
git commit -m "feat: added a new table prefab"
git push origin master

Now our Table of Accessories.prefab is successfully in our remote repository.

Step 9

Now comes the cool part! Open up your Laptop or Tablet of choice. We are using Surface Pro in this example. But it could be anything as long as it can run Unity. This device gets the modifier role in our Assets Pipeline. It is tasked as a separate entity to modifying the Assets that will be used on the producer. On our Modifier, we create a new Unity Project and call it SampleAssetsPipelineModifier.

Step 10

Using GitBash, we clone our assets by running:

cd <path-to-modifier-assets>
git clone <link-to-your-assets-repo>

Step 11

Open the Table of Accessories.prefab and add a new Sphere 3D Object. Position it in the middle. Add a Material to the Sphere to add some spice. Then in the Inspector window, click Add New Component > New Script. Call it Rotate.cs then open it in your favorite text editor and add this line of code in the Update() function:

public class Rotate : MonoBehaviour{ // We don't need this function below void Start() {} // Update is called once per frame void Update() {  transform.Rotate(0.0f, 100.0f * Time.deltaTime, 0.0f); }}

After that, make sure you create a new folder called Scripts in your SampleAssetsPipelineDirectory and add the Rotate script in that folder.

Step 12

Let’s commit our changes by running the following command on GitBash (make sure you are in the SampleAssetsPipelineDirectory root path)

git add .
git commit -m "feat: added a sphere with a rotate function"
git push origin master

Step 13

Switch over to your VR ready PC (the producer) and run the following command in the SampleAssetsPipelineProject directory path:

git pull origin master

Reload the scene. You should be able to see the Sphere 3D Object floating on the Table of Accessories.prefab now! The sphere does look questionable … but hey! Our pipeline works! Ta-da!!!

We can also be a little naughty and add our own material to the table!

That’s all guys! Try spicing it up a bit. What if this sphere was moving quicker? What if there are items you can grab and play around with? The results are endless. As long as you have your Assets Pipeline working on more than one device, you can bet on editing your favorite VR project on the go!

Thank you for reading and let me know if you have any comments.

mk

--

--