Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Adding labels programatically

Discussion in 'Addressables' started by Jaimi, Nov 7, 2019.

  1. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    4,851
    I'm generating AddressableAssetGroups and adding AddressableAssetEntrys to them programatically (for UMA). This is generating correctly so far.
    But when I go to add a label to the AddressableAssetEntry, it doesn't appear to do anything. I don't see it in the UI after the fact.
    I've tried manually adding a string to the labels property.
    I've tried using SetLabel(labelstring,true);

    SetLabel returns true.

    But I don't actually ever see the label on the AddressableAssetEntry in the "Addressable Groups" editor.

    Am I doing something wrong?
     
  2. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    81
    Hey @Jaimi try setting the next parameter in SetLabel to true as well. This will force your label to be added to the Addressable Asset Settings label table. So use
    Code (CSharp):
    1. myEntry.SetLabel(label, true, true);
    I'm not sure if the UI will update automatically or if you'll need to post the event as well. If you do want to post the label event use
    Code (CSharp):
    1. myEntry.SetLabel(label, true, true, true);
    the last parameter will tell the system to post an event when a label is added to the label table

    Hope that helps!
     
  3. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    4,851
    Perfect, that did it. Thanks!
     
    DavidUnity3d likes this.