docs.unity3d.com
    Show / Hide Table of Contents

    Sample: Integrate Annotations in a Unity Cloud scene

    You can use the Annotations sample to leave annotations in your Unity Cloud scene and synchronize your annotations data with the cloud.

    The sample uses a 2D user interface. For more information about using 3D-related user interface fields, see the Go further section.

    Prerequisites

    Before you use the Annotations sample, you must have the following:

    • Installed Annotations, Identity, and Storage packages
    • A valid Unity ID
    • A Unity Cloud scene associated with your Unity ID

    Note: While the Annotations service doesn't depend on the Identity or Storage services, they're used in the sample to control the authentication flow.

    Installation

    To install the sample, follow these steps:

    1. Inside your Unity project window, go to Package Manager > Unity Cloud Annotations.
    2. Expand the Samples section and select Import next to the Topics and Comments sample.
      Screenshot of the samples import section of the package manager window

    After the import process is complete, you can view your imported assets under the Assets/Samples/Unity Cloud Annotation folder.
    Screenshot of the imported sample

    Add Annotations to your Unity Cloud scene

    The Annotations sample shows you how to create, edit, and delete annotations topics and comments in your Unity Cloud scene.

    Launch the sample

    To launch the sample, follow these steps:

    1. Go to Assets/Samples/Unity Cloud Annotation/<package-version>/Topics and Comments/Scenes/TopicsAndComments.unity and run the scene. If this is your first time launching the sample, make sure to sign in with your Unity ID account. For more information on creating a Unity Cloud scene, see the Storage package documentation.
    2. Select a workspace and scene, and click on Launch Scene. The scene retains any annotations previously left on it.
      Screenshot of the login window

    Create topics and comments in the sample

    To create a topic and a comment in the sample, follow these steps:

    1. Select Create Topic.
    2. Enter a topic title and select Confirm. You can find your new topic in the topic scroller.
      Screenshot of the created topic
    3. Enter a comment in the comment input field.

    The topic and comment creation dates are in UTC time.

    Edit topics and comments in the sample

    To edit a topic and a comment in the sample, follow these steps:

    1. In an existing topic, go to the Options menu (…).
    2. Select Edit to edit the topic title.
    3. In an existing comment, go to the Options menu (…) in the comment box.
    4. Select Edit to edit the comment text.

    Resolve topics in the sample

    To resolve topics in the sample, follow these steps:

    1. In an existing topic, go to the Options menu (…).
    2. Select Resolve. A green check mark appears to mark the topic as resolved.
    3. (Optional) To reverse the resolved status of a topic, select Unresolve in the Options menu (…).

    Delete topics and comments in the sample

    To delete a topic and a comment in the sample, follow these steps:

    1. In an existing topic, go to the Options menu (…).
    2. Select Delete to delete the topic. If you delete a topic, all the comments associated with that topic are deleted too.
    3. In an existing comment, go to the Options menu (…) in the comment box.
    4. Select Delete to delete the comment.

    Main components

    This section describes the scripts that make up the main components of the Annotations sample.

    Platform services script

    The PlatformServices class initializes and disposes of dependencies required by the AnnotationRepository. You can use this class to manage the Unity Cloud services and dependencies you use in your application.

    To open the platform services script, go to your Assets/Samples/Unity Cloud Annotation/<package-version>/Shared/Scripts/PlatformServices.cs file.

    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().

    Login manager script

    The LoginManager class lets you sign in and provides the Annotations sample with your Unity Cloud scene ID. For more information on authentication, see the Identity package documentation.

    To open the login manager script, go to your Assets/Samples/Unity Cloud Annotation/<package-version>/Shared/Scripts/LoginManager.cs file.

    Annotations sample script

    The TopicsAndCommentsSample script inherits from AnnotationSampleBehaviour, a generic class that shows you how to do the following:

    • Build and use an AnnotationRepository
    • Use a BaseUIController to trigger events for specific user actions (we will be using the TopicUIController class in this sample)
    • Create requests for creating, editing, and deleting annotations
    • Send requests for creating, editing, and deleting annotations to the repository

    To open the Annotations sample script, go to your Assets/Samples/Unity Cloud Annotation/<package-version>/Topics and Comments/Scripts/AnnotationSampleBehaviour.cs file.

    Shared UI scripts

    The UI sample includes a set of UI scripts and prefabs used by annotations. To open shared UI scripts, go to Assets/Samples/Unity Cloud Annotation/<package-version>/Shared/Scripts/UI.

    Go further with your sample

    This section describes other actions you can perform with the Annotations sample.

    Create annotations with more data

    You can include other fields in your annotations such as topic descriptions, object IDs, and 3D transform information of the annotation relative to these objects.

    Test annotation notifications

    The Annotations service sends notifications of changes you make to topics and comments to any users working in the same Unity Cloud scene.

    To test the notifications, you can do the following:

    • Run the sample on two machines using the same Unity Cloud scene.
    • Run two instances of the sample locally.

    Troubleshoot

    This section describes issues you might have while using the Annotations sample.

    Missing dependency

    If you get a missing dependency error about a specific package, ensure you have installed all the packages listed in the Prerequisites.

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

    Login Successful

    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 isn't 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.

    Input system settings

    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