Search Unity

Feedback [Suggestion] Loading Group of Assets with Folder Name

Discussion in 'Addressables' started by JonTerp, Mar 3, 2019.

  1. JonTerp

    JonTerp

    Joined:
    Aug 20, 2014
    Posts:
    9
    Currently, we are able to load a group of assets using the label key. But it'd simplify certain workflows to be able to address groups of assets by their addressable folder name.

    Those of us loading groups of assets for many different contexts would leave us with tons of addressable labels. Which is not an ideal and pretty unwieldy.

    I noticed via the Addressable window you can drag entire folders in and it brings all the objects in and does ... something else? Not entirely sure what this affects but it greys out all items contained within the folder and only allows you to label them. No simplifying their names and such.

    Anyways, it'd be great to expand upon this by allowing us to address entire groups of objects not just via labels, but via their folder name too.

    (If I'm missing a clear existing solution to this please let me know)
     
    SNeakita, ErotesGames and CyRaid like this.
  2. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    As far as I know, if you drag directories in you can then load by the directory address. However, that does mean that you can no longer customise the addressable address of items in it.
     
  3. JonTerp

    JonTerp

    Joined:
    Aug 20, 2014
    Posts:
    9
    I tried this and it failed to load every time. Address was not found. Loading by label in this way worked fine.

    edit: Took a look at the Resource Locators map when loading assets and it seems that it only contains direct asset locations and labels. I assume it might be possible to have a function that parses this map and finds all assets containing a certain folder path and just go that route. I wrote a similar function when working with asset bundles.

    Or even more hacky: Write a custom build script to turn non-sub assets into labels at build time. Probably possible and totally ill-advised.
     
    Last edited: Mar 5, 2019
  4. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    Hm. @unity_bill, thoughts? It's been many months since I last looked at this.

    Not ideal, but customising the build process is pretty normal, they are trying to make it increasingly customisable with every release.
     
  5. JonTerp

    JonTerp

    Joined:
    Aug 20, 2014
    Posts:
    9
    Bumping. It'd be nice to get an official word on this. @unity_bill ?
     
  6. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    +1, make sense for me.

    If I want to load a group of asset of one type, It's trivial to organize those assets into one folder. Like all your icons into Assets/images/icons. Current workflow encourages us to label those assets with "images_icons" label. If new assets commit into that folder, you need sync addressables yourself, or write a script to automate.

    I imagine that when you drag a folder into addressables, the system could ask whether you want to track the changes of folder or just one-time import. And either way we could load assets by folder (or even path matched given regex).
     
    ErotesGames likes this.
  7. JonTerp

    JonTerp

    Joined:
    Aug 20, 2014
    Posts:
    9
    I've done some research. It seems that writing a custom Locator with this functionality wouldn't be too hard. But before looking into that I wrote some probably super hacky code I don't recommend you use. There are better solutions but this is the quick and dirty proof of concept.

    If @unity_bill or otherwise wants to jump in and let me know the intended way to extend addressables in this sense please be my guest.

    https://gist.github.com/JonTerp/cedaf913589fe1fb082634d0a2c73b8f
     
    Digika and Favo-Yang like this.
  8. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Based. Thanks!