docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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:

    1. In your Unity Editor Project, go to Window > Package Manager > Unity Cloud Data Streaming.

    2. Expand the Samples section.

    3. 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:

    1. In your Unity Editor Project, go to File > Open Scene.

    2. Go to Assets/Samples/Unity Cloud Data Streaming/<package-version>/Instance Modifier Sample/Scenes/InstanceModifierSample.unity and run the scene.

    3. 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.

    4. Log into the browser window that launches with your Unity ID account.

    5. Return to the sample scene to confirm that you are logged in. The Workspace field lists the workspaces associated with your account.

    6. From the Organization field, select an organization.

    7. From the Project field, select a project.

    8. From the Asset field, select an asset.

    9. Select Launch to download and view the associated dataset.

      Screenshot of a selected Workspace and Scene with Launch Scene enabled

    10. Instructions on how to navigate the scene are on the screen. Screenshot of a launched demo scene with instructions

    11. Clicking on an instance will highlight it. Clicking on it again will unhighlight it.

    12. By changing the selection mode on clicking on the Selection Mode button will change the selection mode to visibility mode. Screenshot of the selection mode

    13. Now, when clicking on an instance, it will be hidden.

    14. 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.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)