docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License

    • Storage
      • Installation
      • Getting started
    • Use Cases
      • Getting workspace and scene information
    • Samples
      • Getting workspace and scene information

    Storage sample

    This sample demonstrates how to retrieve Digital Twin workspaces and scenes a user has access to. You will be able to view the workspaces associated to your Unity ID and information about these workspaces, as well as all the scenes part of said workspaces.

    Prerequisites

    • An installation of the Storage package via the installation instructions.
    • An installation of the Identity package.
    • A Unity ID.
    • Any number of Digital Twins workspaces and scenes associated to your Unity ID.

    Note: The Storage package does not directly depend on the Identity package, however in order to log in and retrieve Digital Twins storage information for an account, it is used in this sample to control the authentication flow.

    Workspaces and scenes sample

    This sample will retrieve and display all the storage information associated to your account. You can select specific workspaces to view information about them, as well as all the scenes associated to each workspace. Selecting specific scenes will also display information about these scenes.

    Installation

    Importing the package samples is done via the Package Manager window, which will automatically copy the necessary assets into your base project.

    1. Inside your Unity project, go to Window > Package Manager and select the Digital Twins Storage package
    2. Expand the Samples section in the package window, and click Import on the Workspaces and Scenes sample.
      The samples import section of the package manager window
    3. Wait for the import process to complete, and view the imported assets under Assets/Samples/Digital Twins Storage.
      The imported sample

    Troubleshooting

    Console Error: Missing dependency to com.digital-twins.identity package.

    This sample requires the Identity package to be installed. If it is not, you will see the following error in your console:

    error CS1029: #error: 'Missing dependency to com.digital-twins.identity package.'

    Add the Identity package to your project via the Package Manager in order to import and run the sample.

    Running the sample

    Running the sample is done via the WorkspacesAndScenes scene.

    1. Open the sample at Assets/Samples/Digital Twins Storage/<package-version>/Workspaces and Scenes/WorkspacesAndScenes.unity and run the scene.
    2. If you are not logged in, you should see an enabled Login button and no user name. If you have previously logged in, the sample will attempt to automatically log you in, after which you can skip to step 5.
      User is logged out
    3. Click the Login button. You should see the status has been updated to "Logging in...". A browser window should launch allowing you to login via your Unity ID account. Follow the steps, and once successfully logged in, you should see the following browser message.
      Browser message
    4. Return to the sample scene. You should now be logged in.
    5. The workspaces section should now be populated with buttons for each of the workspaces associated to your account. Click on a workspace button to see the info for that workspace.

      Workspace section
    6. If there are scenes associate to a workspace, the Scenes section will populate with buttons for each of the scenes. Click on a scene to view information about that scene.
      Scene section

    Key Components

    If you're interested in seeing how the sample is built, below is a short description of the key components that should demonstrate how to use the Storage services to retrieve and view storage information.

    WorkspacesAndScenesSample.cs

    File Location: Assets/Samples/Digital Twins Storage/<package-version>/Workspaces and Scenes/Scripts/WorkspacesAndScenesSample.cs

    This is the main script for the sample, showing how to retrieve workspaces and scenes via an IWorkspaceProvider and IWorkspace. View the PopulateWorkspaces() and PopulateScenes() methods to see how this information is retrieved and fed to the sample's ContentScroller UI.

    The sample use an IAuthenticator to get events when the user is logged in or out. See documentation on the Identity package for more details on user authentication.

    Platform Services

    File Location: Assets/Samples/Digital Twins Storage/<package-version>/Common/Scripts/PlatformServices.cs

    This class is responsible for initializing and disposing of the IWorkspaceProvider, as well as all the dependencies it requires. It exposes the provider via a property such that any component which needs to retrieve workspace information can use this provider.

    The accompanying classes, PlatformServicesInitialization and PlatformServicesShutdown are components which are used to call the initialization and shutdown methods through Unity's standard Monobehaviour methods: Awake() and OnDestroy().

    Login Manager

    File Location: Assets/Samples/Digital Twins Storage/<package-version>/Common/Scripts/LoginManager.cs

    This class is responsible user login. See documentation on the Identity package and its samples for more details on user authentication.

    Troubleshooting

    I don't see any workspaces or scenes.

    Ensure that you have successfully created at least one Digital Twins scene via the Digital Twins Asset Manager on the Digital Twins Portal

    Back to top Generated by DocFX
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023