Using the Motive Asset Bundler and Spawning an Asset with a Storyflow Script

In depth learning on Asset Bundles and Spawning Assets can be found in this course in Motive Academy.

 

Overview

This article describes how to use the Asset Bundler which is part of the Motive Unity SDK. It allows you to upload one or more Bundles to Storyflow directly from Unity.

Once in Storyflow, any Asset which is part of the Asset Bundle can be injected into a Scene using a Storyflow Script.

Video

This video follows the same steps outlined below.

Step 1: Unity - Add an Asset Bundle Tag to a Prefab

The Prefab in this example is called Sphere Asset. It has a Motive Scene Object Script and it has the name MySphere.

Remember the name of the Prefab and the Motive Scene Object.

  1. Select the Prefab you want to add to an Asset Bundle

  2. In the Inspector, go to the very bottom of the tab to the “Asset Bundle” field

  3. Click on the drop down menu and select the name of the Asset Bundle that you want to add this Prefab

    1. If you don’t yet have a name, click New… and type in the name

Important: Do not use spaces or special characters in the name

Step 2: Unity - Use the Motive Asset Bundler

  1. From the main menu bar on the top of the screen, select Motive > Asset Bundler > Window

The Motive Asset Bundler has several sections. Below are the instructions for each section:

Bundle Configuration

  1. Check the box next to the name with which you tagged your Prefab in the step above

Select Build Targets

  1. Check the box next to “Android”

Build Configuration

  1. Click the “Choose Folder” button

  2. Select a folder into which the Asset Bundle will be built. This can be any folder. If you are not sure, create a new folder called Asset Bundles and use that.

Server Configuration

Motive Cloud URL

  1. Set this to the URL of your Motive instance (For example, https://preview.motivecloud.dev)

  1. Click the Login button

  2. A nine digit code will appear below the button - make note of the code

Step 3: Storyflow - Authenticate the Asset Bundler

  1. In your Storyflow project, enter the nine digit code into the Authenticate Device text box on the left-hand side

  2. Click the checkmark button

The Asset Bundler is now authenticated.

  1. Return to Unity

Step 4: Unity - Continue with the Motive Asset Bundler

The nine digit code will no longer appear.

Manage Upload

Media Catalog

This is the name of the Media Item Catalog that the Asset Bundle will be placed in your Storyflow project

  1. You can use the default name or choose your own. If the Catalog does not already exist, it will be created for you

Bundle Catalog

This is the name of the Unity Asset Bundle Catalog that the asset Bundle will be placed in your Storyflow project

  1. You can use the default name or choose your own

    1. If the Catalog does not already exist, it will be created for you

Click to load organizations

  1. Click this button to load your organizations

  2. Select an organization

Select a Space

  1. Click the button to open a drop down and select your space

Select a Project

  1. Click the Projects button to choose your Storyflow project

This may take a few moments to complete. Once it is done, you can close the Motive Asset Bundler window.

Step 5: Storyflow - View the Catalogs (optional)

  1. Go to your Storyflow project

  2. Notice that the following Catalogs now exist:

    1. Media Item Catalog

      1. A Media Item was also added to the Media Library

      2. It is now referenced in this Catalog

    2. Unity Asset Bundle Catalog

    3. Unity Asset Catalog

      1. This contains a Catalog item with the name of your Prefab (Sphere Asset in this example)

Step 6: Storyflow - Add the Object to a Named Object Catalog

  1. Remember the name of the Motive Scene Object from step (MySphere in this example)

  2. Add this as a Catalog item to a Named Object Catalog

    1. If you have already done this, you can skip this step

Step 7: Storyflow - Spawn the Asset with a Storyflow Script

  1. Create a new Script

  2. Link the Script to a Scenario

  3. Call the first child Frame Setup

  4. Add a Spawn Asset Resource

  5. Select the Prefab name from the Unity Asset Catalog (Sphere Asset)

  6. Add a Scene Object Resource

  7. Add the object with Motive Scene Object name from step 6 (MySphere)

  8. Add a Scene Anchor (optional)

    1. An anchor is used to define where the Asset will spawn in the Scene

    2. Depending on the Scene, you may want to use different anchors

Do these next steps if you are using a Scene Anchor:

  1. Create a child Frame of the Setup frame with the Condition that the Spawn Asset Resource is complete

  2. Add a Move Object Resource

  3. Select the Scene Object from the Objects menu

  4. Select the Anchor from the Anchor menu

Step 8: Unity or Headset

  1. Run the Storyflow Scenario that is linked to the Script created in step 7

The Asset Bundle will be downloaded like any other piece of Media and spawned into the Scene at the coordinates defined in the Anchor.

You can try running the same Script in another Scene. You may want to use a different Anchor in your Storyflow Script but the Asset will appear just as easily in any other Scene with the same Storyflow Script.

Related Articles

Walkthroughs