Sample: Stream a Unity Cloud scene in a Unity project
You can use this sample to stream a scene from the cloud. You can choose which scene to view and move the camera around the scene to see the data streaming function.
Prerequisites
To use the Data Streaming cloud scene sample, you require the following:
- An installed Data Streaming package and its dependencies
- An installed Identity package
- An installed Storage package
- A valid Unity ID
- At least one Unity Cloud scene associated to your Unity ID
Note: Other than the dependencies listed in the installation instructions, the additional dependencies listed are required only to run the samples. The additional dependencies aren't required to use the base package.
Warning: This sample is designed to work on PC and may not behave as expected on other platforms like iOS and Android.
Installation
To install the sample, follow these steps:
- In your Unity project, go to Window > Package Manager > Unity Cloud Data Streaming.
Expand Samples and select Import beside the Cloud Scene Sample.
After the import process completes, you can view the imported assets under the
Assets/Samples/Unity Cloud Data Streaming
folder.
Run the sample
To run the sample, follow these steps:
- In your Unity project, go to File > Open Scene.
- Go to
Assets/Samples/Unity Cloud Data Streaming/<package-version>/Cloud Sample Scene/Scenes/CloudSceneSample.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.
- Select a workspace from the Workspace field and then select a scene from the Scene field.
Select Launch Scene to download and view the associated scene.
Instructions on how to navigate the scene are on the screen.
Main components
This section describes the scripts that make up the cloud scene sample.
Cloud scene sample script
The CloudSceneSample
class demonstrates how the DataStreamer
is used to launch a scene. The selected
scene is provided as an IScene
parameter. The IScene
parameter passes to the DataStreamer
, which loads and displays the associated scene.
To open the cloud scene sample script, go to the Assets/Samples/Unity CLoud Data Streaming/<package-version>/Cloud Scene Sample/Scripts/CloudSceneSample.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 Storage package documentation and samples for information about user authentication and scene information.
To open the login manager script, go to the Assets/Samples/Unity Cloud Data Streaming/<package-version>/Shared/Scripts/Login/LoginManager.cs
file.
Troubleshoot
This section describes issues you might have while using the cloud scene sample.
Can't see any models when the scene runs
To use the Data Streaming package, your project must use either the High Definition Render Pipeline (HDRP) or the Universal Render Pipeline (URP).
Receives the Missing dependency to x.y.z package console error
If you don't have all required packages installed, you receive the following error in your Console window for every missing package: error CS1029: #error: 'Missing dependency to <package name> package.'
Refer to the Prerequisites and make sure all packages are installed.
Can't view any workspaces or scenes
Make sure that you have successfully created at least one Unity Cloud scene through the Asset Manager on the Unity Cloud Portal.
Automatic browser redirection doesn't work
If you run the sample in the Unity Editor, you should see the following page after you successfully login through your browser.
If you aren't automatically redirected to the Editor and nothing happens when you select Launch Application, return to the Editor. This should continue the authentication process.
Mouse input isn't registered
This sample is not created to run with the Input System package. If you are using this package in your project, your mouse selections may not be detected.
To fix this, set your project to support both the built-in input system as well as the Input System package: go to Edit > Project Settings > Player and set Active Input Handling to Both.