Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Changing labels at runtime

Discussion in 'Computer Vision' started by Murray_Zutari, Oct 7, 2021.

  1. Murray_Zutari

    Murray_Zutari

    Joined:
    Jun 1, 2017
    Posts:
    45
    Hi
    Great package, so simple to get up and running.
    We are looking to create synthetic data for understanding percentage complete no a task.
    We'd like to feed the % value into the image label but it's not immediately clear if that is possible. It looks like the Labeling component can only be pre-configured.

    is there a way to do this? If not, would you please consider adding it?
     
  2. MohsenK_Unity

    MohsenK_Unity

    Unity Technologies

    Joined:
    Jun 8, 2021
    Posts:
    10
    Hi Murray,

    Yes, it is possible to do so. This can be achieved through modifying the labels list of the Labeling component. The key is to call RefreshLabeling() on the component after making any changes to the labels. Example:

    Code (CSharp):
    1. var labeling = gameObject.GetComponent<Labeling>();
    2. labeling.labels.Clear();
    3. labeling.labels.Add("new-label");
    4. labeling.RefreshLabeling();
    Keep in mind that any new label added with this method should already be present in the Label Config attached to the Labeler that is supposed to label this object.
     
    d_pepley and Murray_Zutari like this.