docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Use case: Update an attachment of an annotation

    Before you start

    Before you update an attachment of an annotation, ensure you have completed the following prerequisites:

    1. Verify Permissions: Confirm that you have the necessary rights to modify the attachment. Typically, you'll need to be the original creator of the attachment, the annotation owner, or have appropriate administrative permissions.
    2. Identify the Attachment: Locate the specific attachment you want to update. You'll need its unique identifier to perform this action.
    3. Prepare Updated Content: If updating the file content, ensure the new file is ready and meets any system requirements (size limits, file format, etc.).
    4. Set Up SDK Environment: Ensure your Unity environment is properly configured with the Collaboration SDK to interact with the annotation system.

    How do I...?

    Update an attachment

    To modify the name, description, or other metadata of an existing attachment:

    1. Identify the Project Identifier: Ensure you have the correct project identifier (GUID) for the project.
    2. Identify the Annotation: Determine which annotation should receive the attachment.
    3. Identify the Attachment: Determine which attachment should receive the update.
    4. Prepare the Update Request: Create an UpdateFileAttachmentRequest or an UpdateSpatial3DAttachmentRequest object with the new metadata values.
    5. Use the SDK: Call the UpdateAnnotationAttachmentAsync method in the Unity Collaboration SDK with the required properties.
    6. Handle Responses: Ensure your implementation verifies whether the update was successful and handles any errors appropriately.

    Example:

    var projectId = ProjectController.SelectedProjectId.Value;
    var annotationId = new AnnotationId();
    var attachmentId = new AttachmentId();
    var updateAttachmentRequest = new UpdateFileAttachmentRequest(
        filePath: "path/to/attachment.txt",
        fileSize: 12345,
        fileType: "text/plain",
        contentType: "text/plain");
    
    // - or -
    
    var updateAttachmentRequest = new UpdateSpatial3DAttachmentRequest(
        label: "updated-text-for-the-label", // Replace with updated text
        position: new SpatialPosition(), // Replace with updated spatial attachment position
        camera: new CameraDetails(), // Replace with updated camera data structure
        time: new TimeDetails(), // Replace with actual time data structure
        local: new LocalSpaceDetails(), // Replace with actual local space details. Contains data for the attachment with spatial parameters that are relative to parent
     );
    
     // - or -
    
    var updateAttachmentRequest = new UpdateSketchAttachmentRequest(
        sketchData: "{ "dataProperty" : "data" }", // Replace with updated sketch data
        camera: new CameraDetails(), // Replace with updated camera data structure
     );
    
    await annotationManagement.UpdateAnnotationAttachmentAsync(
        projectId: projectId,
        annotationId: annotationId,
        attachmentId: attachmentId,
        updateAttachmentRequest,
        cancellationToken: token
    );
    

    For more information on working with attachments, see the documentation on creating attachments and deleting attachments.

    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)