Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Best grouping strategy

Discussion in 'Addressables' started by AndersonDev, Jun 14, 2019.

  1. AndersonDev

    AndersonDev

    Joined:
    Dec 13, 2015
    Posts:
    62
    Hi. We have a lot of features planed in project, like:
    features/feature1
    features/feature2
    ...
    features/featureN


    1) I want to pack each feature in separate bundle. What is the best way to do it? By labels (feature, my-feature) or by groups?
    All features will be builded by CI.

    2) Moreover each feature should be split by images, prefabs, sounds bundles including dividing for hd, md, sd qualities.

    Will be very thankful for advices!)
     
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    153
    There’re two layers - group and group bundle mode (packing mode).

    Three bundle modes,
    - Packing Together, ends up with one single bundle file.
    - Packing Separately, packs each asset into individual bundle files, ends up with many small bundle files.
    - Pack Together by Label. The name suggests bundle by label, but I'm not sure how it deals with asset with more than one label.

    So if you're okay to deliver feature by feature (like a scene based adventure game). Then you can just give each feature a group, and choose a bundle mode wisely.

    It's majorly a delivery strategy, how small the scale you wish user to fetch update. If your game asset never get updated via network, then it doesn't matter, you can leave everything into the default group.
     
    Last edited: Jun 14, 2019
  3. AndersonDev

    AndersonDev

    Joined:
    Dec 13, 2015
    Posts:
    62
    Like 90% of content will be delivered by network. I thought about: marking all assets in feature folder with "some-feature" label, pack by label and then preload content for that label.

    Divide all features based on label. Or better to use groups for that?

    All this actions will be automated on CI.
     
  4. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    153
    Both can achieve similar results you expect, segment by feature or manually segment by group. The differences are,
    - Group are default way to segment asset, you can still use label for other purpose. And group gives you more control via group settings, which you may need or not.
    - Label on the other hand, is designed for loading a chunk of assets together in runtime I believe, i.e. enemey_set, weapon_icons...

    Just notice that pack by label will create a bundle per unique set of labels. Say you have two labels, feature1, feature2, and 4 assets,

    asset1 - feature1
    asset2 - feature2
    asset3 - feature2
    asset4 - feature1, feature2 # shared asset​

    Pack by label ends up with 3 bundles.

    feature1.bundle, contains asset1
    feature2.bundle, contains asset2 and asset3
    feature1_feature2.bundle, contains asset4​

    If you download feature1 label, it will fetch both feature1.bundle and feature1_feature2.bundles for you.

    There's current a bug in pack by label mode, you need use this patch https://forum.unity.com/threads/bug-bundlepackingmode-packtogetherbylabel-wont-work.694987/
     
    Last edited: Jun 14, 2019
  5. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    33
    I've ended up with the super custom strategy: =)
    * add new mode value: BundlePackingMode.PackSeparatelyByAddressConfigs = 100
    * update bundles preparation logic in BuildScriptPackedMode.PrepGroupBundlePacking() to something custom.
    * read special config-files (`.address-config`) in the Assets/ tree
    ** contains format like: <sub-folder-path-regular-expression>[ = <bundle-name-with-substitution-from-regular-expression>]
    * auto-build process to split assets to separate groups: 'embedded(startup)' and 'downloadable' (basing on Adressables(panel)->Analyse->Duplicate Deps)
    * updated initialization process:
    ** compressed settings/catalog delivery
    ** allow updating settings.json (f.e. includes StartupObjects)
    ** prepend custom ResourceLocator varianting assets (hd/sd/regional)
    * solve or put up with some issues in build/export/load/internal processes..
    * think again and sigh in the day you selected preview package =)
     
    Last edited: Jun 15, 2019
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    We are not using addressables, but in our project we have 2 different strategies for building asset bundles - by label and by folder.
    1. By label - assets need to be marked with a proper asset bundle name, then the asset bundle with the given label can be built.
    2. By Folder - we grab all assets under the given folder and add them into an asset bundle. this doesn't require any prior "marking" like with the first technique.
    We are juggling between both options, not sure which i like best :)
     
  7. AndersonDev

    AndersonDev

    Joined:
    Dec 13, 2015
    Posts:
    62
    Little bit hard to understand :)

    I will have a lot of features (~100). And I need to download resources for each separately in runtime. I think it will be nice:
    - Mark all assets in one folder with some "feature_N" label and pack separately by labels. It will be ~ 100 bundles. Moreover I need to have bundles with different quality levels for each feature.