docs.unity3d.com
    Show / Hide Table of Contents

    Use case | Manage workspaces

    This use case outlines how to set up your project to access and manage workspaces.

    Prerequisites

    Set up a Unity scene

    To set up a Unity scene, follow these steps:

    1. In your Unity project window, go to Assets > Scenes.
    2. Right-click the Assets/Scenes folder.
    3. Select Create > Scene.
    4. Name your scene StorageTest.

    Set up PlatformServices and login to Unity Cloud

    To set up PlatformServices, follow these steps:

    1. Implement the platform services pattern. Refer to Best practices: dependency injection for more information.
    2. Update the PlatformServices class in your PlatformServices file to look like the following:

    Create a MonoBehaviour

    1. In your Unity project window, go to Assets > Scripts.
    2. If the folder doesn't already exist, create an Assets/Scripts folder.
    3. Right-click the Assets/Scripts folder.
    4. Select Create > C# Script.
    5. Name your script StorageBehaviour.
    6. In the StorageTest scene you created earlier, right-click the hierarchy and select Create Empty.
    7. Name your new object StorageExample.
    8. Select the StorageExample object and add the StorageBehaviour script you created earlier.
      Screenshot of the scene setup for the storage example
    9. Update the StorageBehaviour class to look like the following:

    Note: The code sample above automatically logs you in. You can associate the login call with the UI for a better user experience. See the Storage sample page for a UI-driven login and scene selection.

    Manage workspaces

    Create a CloudWorkspaceRepository

    To create a CloudWorkspaceRepository, update the StorageBehaviour class to look like the following:

    Create WorkspaceExamples script

    1. In your Unity project window, go to Assets > Scripts.
    2. If the folder doesn't already exist, create an Assets/Scripts folder.
    3. Right-click the Assets/Scripts folder and go to Create > C# Script. Name your script WorkspaceExamples.

    "Create workspace" example

    1. Update the WorkspaceExamples class to look like the following:
    2. Update the StorageBehaviour class to look like the following:
    3. Paste your organization name into the string named k_OrganizationName. You can find your organization name in Unity Cloud Portal (See Get started).

    "List workspaces" example

    To add List workspaces example, add following code to your WorkspaceExamples class:

    "Delete workspace" example

    To add Delete workspace example, add following code to your WorkspaceExamples class:

    "Workspace metadata" example

    To add Workspace metadata example, add following code to your WorkspaceExamples class:

    Run examples

    1. Replace RunWorkspacesExamples() method in your WorkspaceExamples class with following code:
    2. In Unity Editor, select Play.
    3. Check your console to confirm that you have successfully created, listed, and deleted workspaces as well as added, changed, and deleted metadata.
    Back to top
    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