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.
- 1 Overview
- 2 Video
- 3 Step 1: Unity - Add an Asset Bundle Tag to a Prefab
- 4 Step 2: Unity - Use the Motive Asset Bundler
- 5 Step 3: Storyflow - Authenticate the Asset Bundler
- 6 Step 4: Unity - Continue with the Motive Asset Bundler
- 7 Step 5: Storyflow - View the Catalogs (optional)
- 8 Step 6: Storyflow - Add the Object to a Named Object Catalog
- 9 Step 7: Storyflow - Spawn the Asset with a Storyflow Script
- 10 Step 8: Unity or Headset
- 11 Related Articles
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.
Select the Prefab you want to add to an Asset Bundle
In the Inspector, go to the very bottom of the tab to the “Asset Bundle” field
Click on the drop down menu and select the name of the Asset Bundle that you want to add this Prefab
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
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
Check the box next to the name with which you tagged your Prefab in the step above
Select Build Targets
Check the box next to “Android”
Build Configuration
Click the “Choose Folder” button
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
Set this to the URL of your Motive instance (For example, https://preview.motivecloud.dev)
Click the Login button
A nine digit code will appear below the button - make note of the code
Step 3: Storyflow - Authenticate the Asset Bundler
In your Storyflow project, enter the nine digit code into the Authenticate Device text box on the left-hand side
Click the checkmark button
The Asset Bundler is now authenticated.
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
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
You can use the default name or choose your own
If the Catalog does not already exist, it will be created for you
Click to load organizations
Click this button to load your organizations
Select an organization
Select a Space
Click the button to open a drop down and select your space
Select a Project
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)
Go to your Storyflow project
Notice that the following Catalogs now exist:
Media Item Catalog
A Media Item was also added to the Media Library
It is now referenced in this Catalog
Unity Asset Bundle Catalog
Unity Asset Catalog
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
Remember the name of the Motive Scene Object from step (MySphere in this example)
Add this as a Catalog item to a Named Object Catalog
If you have already done this, you can skip this step
Step 7: Storyflow - Spawn the Asset with a Storyflow Script
Create a new Script
Call the first child Frame Setup
Add a Spawn Asset Resource
Select the Prefab name from the Unity Asset Catalog (Sphere Asset)
Add a Scene Object Resource
Add the object with Motive Scene Object name from step 6 (MySphere)
Add a Scene Anchor (optional)
An anchor is used to define where the Asset will spawn in the Scene
Depending on the Scene, you may want to use different anchors
Do these next steps if you are using a Scene Anchor:
Create a child Frame of the Setup frame with the Condition that the Spawn Asset Resource is complete
Add a Move Object Resource
Select the Scene Object from the Objects menu
Select the Anchor from the Anchor menu
Step 8: Unity or Headset
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