Sample: Instance Modifier Based on Ray Casting
You can use the Instance Modifier Sample to highlight or hide instances based on the user selection.
Important
This sample was 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 Instance Modifier Sample, you must have the following:
- Installed Data Streaming package and its dependencies
- Installed Identity package
- Installed Assets package
- A valid Unity ID
- At least one Unity Cloud streamable asset associated to your Unity ID
Note
The additional dependencies aren't required to use the base package.
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 Instance Modifier 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>/Instance Modifier Sample/Scenes/InstanceModifierSample.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.
Clicking on an instance will highlight it. Clicking on it again will unhighlight it.
By changing the selection mode on clicking on the Selection Mode button will change the selection mode to visibility mode.
Now, when clicking on an instance, it will be hidden.
Clicking on the Reset button will display all hidden instances and unhighlight all highlighted instances.
Main components
This section describes the scripts that make up the Highlight / Visibility Sample.
Instance Modifier Behaviour script
The InstanceModifierBehaviour
class demonstrates how to register an InstanceModifier
to the DataStreamer
and how to trigger it when the user click on an instance.
The InstanceModifierBehaviour
class is accompanied by two classes inherited from the ModifierSample
class.
To open the Instance Modifier Behaviour script, go to the Assets/Samples/Unity Cloud Data Streaming/<package-version>/Instance Modifier Sample/Scripts/InstanceModifierBehaviour.cs
file.
Modifier Sample script
The ModifierSample
class demonstrates how to create a custom InstanceModifier
and how to request the DataStreamer
to update the shaders of the selected instances.
To open the Modifier Sample script, go to the Assets/Samples/Unity Cloud Data Streaming/<package-version>/Instance Modifier Sample/Scripts/ModifierSample.cs
file.
Highlight Modifier script
The HighlightModifier
class demonstrates how to highlight an instance through the InstanceUpdater
.
To open the Highlight Modifier script, go to the Assets/Samples/Unity Cloud Data Streaming/<package-version>/Instance Modifier Sample/Scripts/HighlightModifier.cs
file.
Visibility Modifier script
The VisibilityModifier
class demonstrates how to hide an instance through the InstanceUpdater
.
To open the Visibility Modifier script, go to the Assets/Samples/Unity Cloud Data Streaming/<package-version>/Instance Modifier Sample/Scripts/VisibilityModifier.cs
file.
Troubleshooting
Refer to the troubleshooting section for help with the Instance Modifier Sample.