Search Unity

How can I use AddressableAssetGroups in runtime?

Discussion in 'Addressables' started by pbrito_unity, Apr 16, 2019.

  1. pbrito_unity

    pbrito_unity

    Joined:
    Mar 30, 2018
    Posts:
    24
    I have my assets organized by Addressables groups.
    How can list the groups in a build?

    Thanks.

    EDIT:
    I tried using labels but all I can do is use labels with preLoad or LoadAssets, I can't list addressables by labels.
    How can I use an Addressables "structure" with UnityEngine?
     
    Last edited: Apr 18, 2019
  2. pbrito_unity

    pbrito_unity

    Joined:
    Mar 30, 2018
    Posts:
    24
    I think I'm having the same issue as Sorting Packed Assets Groups thread.
    Having the possibility to organizing assets by group, in the editor, and being able to use that organization in the build, I think, it would be useful.
     
    Last edited: Apr 17, 2019
  3. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    This sounds intersting, but I would like to fully understand your need. Let's imagine you have a group called "FunGroup", and we put a label on everything in that group. what exactly are you wanting when you say you want to "organize" things at runtime?

    `var x = Addressables.GiveMeSomeInformation("FunGroup");`

    What information are you needing? what is `x`?

    Thanks,
    Bill
     
  4. pbrito_unity

    pbrito_unity

    Joined:
    Mar 30, 2018
    Posts:
    24
    Let me create a example:
    Lets say I have a stage, and I want put one charater at a time on stage.
    Each charater will have a voice, soundfx, and a mesh.
    If I have a group for each,a voicesGroup , a soundfxGroup and a meshGroup, then I would do:


    Code (CSharp):
    1. var voice=Addressables.GetGroup("voicesGroup").LoadAsset("charaterA")
    2. var sdfx=Addressables.GetGroup("soundfxGroup").LoadAsset("charaterA")
    3. var mesh=Addressables.GetGroup("meshGroup").LoadAsset("charaterA")

    What I end up doing in my project, was to create a ScriptableObject to manage the Groups in the editor, and then I could use the groups in the build of the game.

    I already have seen people using Addressable groups for Localization, one group for english other for french.
    And then use the path to access:
    Code (CSharp):
    1. Addressables.LoadAsset($"{language}/speakA");
    I'm a small project and I don't like having a complicate build process.

    You already do kind of that with scenes, via Addressables.LoadScene, I think that is like having special group "ScenesGroup" that you can iterate over.

    Another use case :
    if I could iterate over a Group I could for example have a billboard with a random image from a BillboardImagesGroup, without much effort.

    EDIT: I couldn't find a way to list all the addressable items with labelX. Is that possible?
     
    Last edited: Apr 22, 2019
  5. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    ok. so if the group had a label, then you could accomplish what you want with `LoadAssets()` by sending in a List with both "voicesGroup" and "characterA". the texture variations sample has a similar loading pattern: https://github.com/Unity-Technologies/Addressables-Sample/tree/master/Advanced/Texture Variations

    as to the "list all addressable items", you can do `LoadResourceLocations`. This provides the locations. Currently, there's no way to get from those locations back to the address, but we are looking at adding that as there are quite a few use cases.
     
  6. pbrito_unity

    pbrito_unity

    Joined:
    Mar 30, 2018
    Posts:
    24
    I'm doing as you suggested.Thanks.

    I found the use of the word "group" misleading because suggest that you can group assets by commom characteristics.
    But the use cases of groups are for managing and building "assets packages".
    To use groups as I intended in the example feels like a hack.