Sample: Stream a Unity Cloud Asset in a Unity Project
You can use the Cloud Sample to stream an asset from the Unity Cloud. You can choose which asset to view and move the camera around to see how data streaming will only stream the parts which are relevant to the camera's current perspective.
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 Cloud Sample, you must have the following:
- Installed Data Streaming package and its dependencies
- Installed Identity package
- Installed Assets package
- A valid Unity ID
Note
The additional dependencies aren't required to use the base package.
Upload an asset
If not already done, upload an asset to the Asset Manager:
Log into the Asset Manager Dashboard.
Select Add asset to create a new asset.
Name the asset
My First Asset
, drag and drop the files to upload, and execute the 3D Data Streaming workflow.Select Publish asset to finalize.
Note
Depending on the size of the file, it may take some time to run the workflow. When the workflow completes, the asset contains more files than previously uploaded.
Install the sample
To install the sample, follow these steps:
In your Unity Editor Project, go to Window > Package Manager > Unity Cloud Data Streaming.
Expand the Samples section.
On the right of the Cloud sample, select Import.
After the import process completes, you can view the imported assets under the
Assets/Samples/Unity Cloud Data Streaming
folder.
Run the sample
Note
Before you run the samples, you need the additional dependencies installed. See the Before you start section for more information.
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>/Cloud Sample/Scenes/CloudSample.unity
and run the scene.In the Game view, select Login if you are logged out.
Note: If you've previously logged in, the sample automatically logs you in so you can proceed to step 6.
Log into the browser window that launches with your Unity ID account.
Return to the sample scene to confirm that you are logged in. The Workspace field lists the workspaces associated with your account.
From the Organization field, select an organization.
From the Project field, select a project.
From the Asset field, select an asset.
Select Launch to download and view the associated dataset.
Instructions on how to navigate the scene are on the screen.
Main components
This section describes the scripts that make up the Cloud Sample.
Cloud Sample script
The CloudSample
class demonstrates how the DataStreamer
is used to load an asset from the Asset Manager. The selected
dataset is provided as an IAsset
parameter. The IAsset
parameter passes to the DataStreamer
, which loads and displays the associated dataset.
To open the Cloud Sample script, go to the Assets/Samples/Unity Cloud Data Streaming/<package-version>/Cloud Sample/Scripts/CloudSample.cs
file.
Platform services script
The PlatformServices
class initializes and disposes of the Data Streaming service's dependencies and other dependencies that the sample requires. The PlatformServices
class exposes these services so that any component of the sample that requires access to a Unity Cloud service has easy access.
The PlatformServices
class has two accompanying classes called PlatformServicesInitialization
and PlatformServicesShutdown
that call the initialization and shutdown methods through Unity's standard Monobehaviour
methods Awake()
, Start()
and OnDestroy()
.
To open the platform services script, go to the Assets/Samples/Unity Cloud Data Streaming/<package-version>/Shared/Scripts/Services/PlatformServices.cs
file.
Login manager script
The LoginManager
class is responsible for the user login and scene selection. Refer to the Identity package and Assets package documentation and samples for information about user authentication and model information.
To open the login manager script, go to the Assets/Samples/Unity Cloud Data Streaming/<package-version>/Shared/Scripts/Login/LoginManager.cs
file.
Troubleshooting
Refer to the troubleshooting section for help with the Cloud Sample.