Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here:
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question BIM Metadata - using stored data

Discussion in 'Unity Reflect' started by emmabnz, Jul 18, 2021.

  1. emmabnz


    Jan 23, 2018
    Hi there,

    I'm creating a custom stand alone VR application with an imported Revit prefab. At the moment I'm just using Reflect to maintain the link between the Revit project and Unity. However I'd really like to use the information stored within the Metadata script. I've created a small world space UI that pops up when a ray interactor is passed over an object. At the moment the text is inputted manually but i'd really like to be able to populate it with some of the data from the Metadata script. Is this possible? Does anyone have advice on how I can go about this? I'm reasonably new to Unity and C# ReflectHelp.PNG
    Last edited: Jul 18, 2021
  2. GSingland


    Unity Technologies

    Dec 10, 2020
    Hi emmabnz,

    From what I understand, you're already quite close to what you want to achieve, if you already have the UI + the raycast.
    Therefore, I'm going to assume that, in your script, you already found the reference to the game object that contains the metadata you're interested to read. I hope this assumption is correct !

    Here's more or less what you're looking for if you want to iterate through the game object's metadata :
    Code (CSharp):
    1. Metadata metadata = gameObject.GetComponent<Metadata>();
    2. foreach (var couple in metadata.GetParameters())
    3. {
    4.     Debug.Log($"key: {couple.Key}");
    5.     Debug.Log($"value: {couple.Value.value}");
    6.     Debug.Log($"group: {}");
    7. }
    Of course, you would replace the Debug.Log calls with you own code to populate your UI :)

    EDIT : I just realized you might also be looking for what you need to do to actually update the text in your UI ?
    There are many different threads on the web that can help you achieve this part, but the main idea is the following :

    Hope that helps,
    Last edited: Jul 19, 2021
  3. emmabnz


    Jan 23, 2018
    Legend! thank you so much, really appreciate the quick reply!