docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Use metadata

    Pixyz Plugin for Unity has capability to import CAD metadata, such as types, manufacturer information, physical properties, and ownership.

    When you import a model with its metadata into Unity using Pixyz Plugin for Unity, the nodes that hold metadata information are imported to the Metadata MonoBehaviour component of GameObjects.

    Only the GameObjects that have been imported from nodes that hold metadata in the source CAD file contain metadata.

    Get metadata on an imported model

    To get the Metadata block of a GameObject, run this command:

    Metadata metadata = gameObject.GetComponent<Metadata>();
    

    Check whether a property exists

    To check whether a property exists or not based on its name, run this command:

    bool hasWeight = metadata.containsProperty("Weight");
    

    Get a property value

    To get a property value, run this command:

    string value = metadata.getProperty("Weight");
    

    If no property with the specified name exists, then an error is thrown.

    Add a property

    To add a property to the Metadata block, run this command:

    metadata.addOrSetProperty("Weight", "756kg");
    

    Set a property value

    To set a property value, run this command:

    metadata.addOrSetProperty("Weight", "354kg");
    

    If the property already exists, the value is updated with the specified value.

    Get properties as a dictionary

    To get all the properties in the form of a dictionary, that is, with unique keys, run this command:

    Dictionary<string, string> properties = metadata.getProperties();
    

    Remove a property

    To remove a property from a Metadata block, run this command:

    metadata.removeProperty("Weight");
    

    If the removal succeeds, True is returned.

    The removal might fail, for example if no property with the specified name exists. In this case, False is returned.

    In This Article
    Back to top
    Copyright © 2024 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)