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.

MetaData search/query without pipeline when using prefab.

Discussion in 'Unity Reflect' started by garrido86, Dec 2, 2020.

  1. garrido86

    garrido86

    Joined:
    Dec 17, 2013
    Posts:
    229
    I'm currently working with the generated Prefab(s) from the imported Revit model and I like to know how I can query for meta-data. As I understand the existing tooling is meant to be used with the Pipeline when loading a Reflect project "on demand" but this is not the case for me.

    I think there must be a way, because the Editor MetaData Explorer from the Reflect-Extensions allows me to actually work and query the Prefab without interfacing with the Reflect Pipeline, but I couldn't figure out how it is doing it looking at the code: https://github.com/Unity-Technologi...or/MetadataExplorer/MetadataEditorExplorer.cs

    I could write up my own little query manager but meh, I think there must be a pre-existing way to handle this.
     
  2. FredMoreau

    FredMoreau

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    33
    Hi,

    I understand you want to query metadata at runtime, from a model you imported through the Reflect window in the Editor.

    You may also want to look at this other Editor Metadata Explorer for hints:
    https://github.com/Unity-Technologi...c/Editor/MetadataExplorer/MetadataExplorer.cs

    Every object featuring metadata has a Metadata component, so the following will provide you with all the metadata in the scene :
    metadatas = FindObjectsOfType<Metadata>();

    Then you can iterate to find the parameters and metadata :
    foreach (Metadata m in metadatas)
    {
    var parameters = m.GetParameters();
    foreach (KeyValuePair<string, Metadata.Parameter> kvp in parameters)
    {
    }
    }

    Hope this helps.