docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Use case: Create a reaction to an annotation

    Before you start

    Before you create a reaction to an annotation, ensure you have completed the following prerequisites:

    1. Verify Permissions: Confirm that you have the necessary rights to add reactions to annotations. This typically requires being a member of the project with appropriate permissions.
    2. Existing Annotation: You must have an existing annotation to which you want to add the reaction. Make sure you have its unique identifier.
    3. Understand Available Reactions: Familiarize yourself with the types of reactions supported by the system. Common reactions include:
      • 👍 (Thumbs up / Like)
      • 👎 (Thumbs down / Dislike)
      • ❤️ (Heart)
      • 😄 (Laugh)
      • 😮 (Surprised)
      • 🎯 (Bullseye)
      • ✅ (Checkmark)
    4. Consider Reaction Context: Understand the purpose and implications of reactions in your team's workflow. Reactions provide quick feedback without cluttering the discussion thread.
    5. Set Up SDK Environment: Ensure your Unity environment is properly configured with the Collaboration SDK to interact with the annotation system.

    How do I...?

    Add a standard reaction to an annotation

    To add a predefined reaction to an existing annotation:

    1. Obtain the Project Identifier: Ensure you have the correct project identifier (GUID) for the project.
    2. Identify the Annotation: Determine which annotation should receive the reaction.
    3. Choose the Reaction Type: Select one of the standard reaction types supported by the system.
    4. Create the Reaction: Use the SDK to add the reaction to the annotation.
    5. Handle UI Updates: Update your user interface to reflect the newly added reaction, typically by incrementing a counter and highlighting that the current user has reacted.
    6. Validate Support: Ensure the system supports the specific emoji before attempting to use it.

    Example:

    var projectId = new ProjectId("example-project-id");
    var annotationId = new AnnotationId("example-annotation-id");
    var code = "thumbs_up"; // Reaction code for 👍
    var cancellationToken = new CancellationTokenSource().Token;
    
    await annotationManagement.CreateAnnotationReactionAsync(
       projectId: projectId,
       annotationId: annotationId,
       code: code,
       cancellationToken: cancellationToken);
    

    If a user has already reacted to an Annotation with the given emoji, then this operation does nothing.

    Handle reaction creation errors and duplicates

    To manage potential errors or duplicate reactions:

    1. Implement Error Handling: Add robust error handling for the reaction creation process.
    2. Check for Duplicates: Handle cases where a user might try to add the same reaction multiple times.

    For more information on working with reactions, see the documentation on deleting reactions.

    See the API documentation for more details on the CreateAnnotationReactionAsync method.

    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)