Sample: Stream and Move Multiple Models
You can use this sample to stream multiple models from the Unity Editor project StreamingAssets
directory. You can choose which models to view, move the camera around the models, and move the models in the scene.
Important
This sample is designed to work on PC. It may not behave as expected on other platforms, such as iOS or Android.
Before you start
Before you use the Data Streaming multi-model sample, you must have the following:
Important
This sample is designed to work on PC and may not behave as expected on other platforms like iOS and Android.
Install the sample
To install the sample, follow these steps:
- In your Unity project, go to Window > Package Manager > Unity Cloud Data Streaming.
- Expand the Samples section.
- On the right of the Multi-Model sample, select Import.
- When requested to import the sample files into the
StreamingAssets
folder, clickYes
.
After the import process completes, you can view the imported assets under the Assets/Samples/Unity Cloud Data Streaming
and Assets/StreamingAssets/MultiModel
folders.
Run the sample
To run the sample, follow these steps:
- In your Unity Editor project, go to File > Open Scene.
- Go to
Assets/Samples/Unity Cloud Data Streaming/<package-version>/Multi-Model Sample/Scenes/MultiModelSample.unity
. - Run the scene.
- To stream a model, toggle some of the checkboxes.
- To move the stage, select the StageTransform game object in the Hierarchy window and change the values of the Transform component.
- To move a specific model, select its game object under StageTransform in Hierarchy window and change the values of the Transform component.
Main components
This section describes the scripts that make up the multi-model sample.
MultiModelSample script
The MultiModelSample
class connects the 3 scripts together. It first launches the IDataStreamer, add the available model paths to the UI, and add or remove models from the streamer based on the state of the UI toggles.
To use a custom dataset, put your json and glb files inside Assets/StreamingAssets
, select the MultiModelSample
game object, and add the path to the collection of paths in the inspector.
TransformController script
The TransformController
class receives all displayed models and associates each of them with a game object and a transform in the scene hierarchy under the StageTransform
game object. It then synchronizes the values of these tranforms with the transforms applied to the models that are currently on the stage.
UIView script
The UIView
class displays the checkboxes for the models onto the Canvas and fires an event every time a toggle is toggled by the user.
Troubleshooting
Refer to the troubleshooting section for help with the sample.