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 have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to accessing specific addressable group

Discussion in 'Scripting' started by UMURAS, Mar 11, 2022.

  1. UMURAS

    UMURAS

    Joined:
    Jun 15, 2019
    Posts:
    18
    Hello, I have an addressable group where I keep objects, there are many prefabs in it, I want to access them in the game object type with code and change their materials, but I could not do it. I was able to access the group name, but I can't access the game objects in it, can you please help?
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,385
    This question is probably best asked in the Addressables forum:
    https://forum.unity.com/forums/addressables.156/

    With that said... and take this with a grain of salt as I only recently just started working with Addressables. But I don't think you're able to access them by group at runtime.

    You can create labels to associate assets together and retrieve the keys for everything of a given label.

    You can create catalogs of assets.

    But I don't know of a way to get all the keys of a specific group.

    ...

    You say:
    What do you mean?

    Can you share with us the code you have?
     
  3. UMURAS

    UMURAS

    Joined:
    Jun 15, 2019
    Posts:
    18
    var setting = AddressableAssetSettingsDefaultObject.Settings;
    if (setting!=null)
    {
    var group = setting.FindGroup("Balls");
    if (group != null)
    {
    Debug.Log(group.name);
    }
    }

    Thanks to this code, I can find and print the name of the addressable group, but I don't know how to access the gameobjects in that group.
     
    leshem_unity likes this.
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,385
    leshem_unity likes this.
  5. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
    Groups are meant to help you keep your assets organized and to set certain settings for the way those groups are compiled when making a build. They're not meant to be used at runtime, and to my knowledge I don't think the groups even exist at runtime. In the manifest I believe all the assets are compiled into a list linking each address to its bundle, so at runtime the group is bypassed entirely.

    Apply a label to everything in the group, and load assets via that label.
     
  6. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,385
    Yeah, that was my general take away too. Just never got a confirmation anywhere. The documentation for Addressables is lacking compared to the main Unity API... IMO.
     
  7. unity_CD1903AF7A6B933582E3

    unity_CD1903AF7A6B933582E3

    Joined:
    Feb 16, 2023
    Posts:
    1
    lacking is an understatement
     
  8. Elhimp

    Elhimp

    Joined:
    Jan 6, 2013
    Posts:
    71