Search Unity

Simpler Alternative to Addressables.

Discussion in 'Addressables' started by locus84, Feb 3, 2020.

  1. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    It would be nice if there was a way to find all scenes or all assets of type without having to specify a bundle name. My use case is optional local bundles, each with a single scene and its content that i like to enumerate and use by availability.
    Or is there already and i just don't see it?
    I only poked around with intellisense, but it doesn't look like it.
     
  2. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    I think I should maintain current api about this.
    Because there can be naming collisions as well as memory and performance pressure to create
    additional asset mapping whenever you load new bundle. But I do think AssetReference(which I plan to add) resolves that issue partially. As I mentioned before, I'd like to keep this library simple and the AssetReference functionality also designed to be toggled for those who prefer strict asset mapping and performance.

    Regards!
     
    Kazko likes this.
  3. St-Aaron

    St-Aaron

    Joined:
    Oct 7, 2020
    Posts:
    11
    Hi, I recently switched development from Ubuntu to Windows 10 and now I'm facing this problem where the UnityWebRequest.Get(Path.Combine(RemoteURL, AssetbundleBuildSettings.ManifestFileName)); in the BundleManager throws UriFormatException: Invalid URI: The hostname could not be parsed.

    The issue seems to be with the forward and backward slashes that Path.Combine uses on Windows.
    https://xxx.digitaloceanspaces.com/Android/Manifest.json <=== works as intended (hardcoded for testing)
    https://xxx.digitaloceanspaces.com\Android\Manifest.json <=== throws the error

    Any idea how to handle this?

    Edit: the problem only seems to occur when testing with remote url in the editor on Windows.
     
    Last edited: Mar 3, 2021
  4. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there.

    Can you share your settings(without sensitive informations if there are)?
     
  5. St-Aaron

    St-Aaron

    Joined:
    Oct 7, 2020
    Posts:
    11
    The setup is pretty basic. I worked around it for the moment by using the Emulate without remote URL option, but would like to test it in editor with remote data as well :)
    Here's a screenshot of the settings: Screenshot 2021-03-03 182844.png
     
    locus84 likes this.
  6. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Thank you for the information, I've pushed temporary fix for this problem.
    Please use latest version in the github for now.

    I'll ping here when it's cleaned and tagged.
     
    Last edited: Mar 6, 2021
  7. St-Aaron

    St-Aaron

    Joined:
    Oct 7, 2020
    Posts:
    11
    Ok, the fixes seem to have done the job! Thanks for the quick reply and action as always!
     
    locus84 likes this.
  8. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    Does this bundle system support webGL browser builds? I made a webGL build of my game but only a black screen shows whenever It's built and I want to make sure it's not the bundle system causing this.
     
  9. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hello.

    I haven't tried that myself, what I can say is that it may work as assetbundle supports webgl.
    I can test in weekend maybe, or you can send me sample project when you stumble.

    Regards.
     
    nichjaim likes this.
  10. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    The game seems to crash when trying to load stuff when Emulate in Editor is set to active. Does this mean that for sure the bundle system is causing the problems or is Emulate in Editor just not as accurate when project is targeting webGL?
     
  11. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hmm... guess the second. Can you try actual build?
     
  12. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    Probably not your area of expertise but thought I'd ask anyway, this error seems to pop up in the browser console when I try to run the build. Is this just a generic webGL error or is there something in particular it's telling me? Link: https://hatebin.com/elqwrkmhri

    EDIT: I commented out the code that initializes the bundle manager and the error went away (but the black screen didn't, so that particular problem might be unrelated)

    EDIT 2: I read somewhere that asset bundles work a bit different on webGL builds? Do I need to change any settings in this bundle system or can I just use it as I would with any other platform?

    EDIT 3: (sorry for so many edits) I made a new blank project that uses this bundle system and when running a webGL build of it, I got the same error when the game tries to initialize the bundle system. I'm not sure if I have to change some settings for webGL or if this bundle system is just not compatible with newer unity webGL builds. Did anyone else get a webGL build working properly that uses this bundle system?
     
    Last edited: Mar 14, 2021
    locus84 likes this.
  13. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Thank you for the test, can you send me the last test project so i can see the same result with you??
     
  14. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    It's just something I whipped up real quick and very amateur, not sure if I'm doing things right. There is a floating sprite in middle of game area, press 1, 2, and 3 when in game to switch the sprite to a loaded sprite asset. Not sure what is traditional way to send a unity project so I'm just gonna provide storage site link. Also unsure how people generally test webGL builds but I just upload it to itch.io. If I sent the wrong thing or you need/prefer it in a different form or through different delivery method please just let me know.

    Bare-bones WebGL project link: https://mega.nz/folder/vohiibIZ#edc_I6GdHIFEASm2KkIBQQ
     
    locus84 likes this.
  15. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    No worries, I'll make it run. just wait for me.

    Regards.
     
  16. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119

    http://specter.myqnapcloud.com:81/Test/WebGL_Build/index.html

    Here's fixed version you can try.
    Please use latest version in the github for now.

    The fix will be included next release.

    Thank you for the report.
     
    nichjaim likes this.
  17. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    Holy moly, you're a freaking wizard! How would I update my existing project with the new version?
     
  18. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Just remove this package from the project and re-install.
    Or remove this package from Packages/packages-lock.json.

    upload_2021-3-14_15-25-51.png
     
    nichjaim likes this.
  19. Klausini

    Klausini

    Joined:
    Feb 19, 2010
    Posts:
    37
    First of all, this is an awesome tool! Many, many thanks!
    I am sorry for my noob questions! In my case, I would like to add new scenes to an app along with further development. My approach was an online config file and a bundle for each scene (scene + resources bundle actually). Each scene should be locked first. Only when unlocked (or when an update is on the server) this specific scene should be downloaded once before loading.
    How can I download only one full resource bundle + scene bundle? I only figured out how to load all bundles.

    Second noob question: When I mark a bundle as "included in player" why is it in the RemoteBundles' manifest and needs to be downloaded anyway?
     
  20. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there.

    1. Check below.

    2. You can manage it like assetbundle(so you can manage memory). Plus you can update it even it's included in player.
     
  21. Boemak

    Boemak

    Joined:
    May 29, 2013
    Posts:
    48
    This look good. Will the following work: I have a base app with all the scripts needed: Can I use your system to create extra levels and update assets/scenes without needing to touch the application that is already installed?

    I just want the base application to not host any content and just download levels, that might be updated on the backend, as needed.
     
  22. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Yes you can do that, actually that's one of main purpose of using assetbundles.
     
  23. Boemak

    Boemak

    Joined:
    May 29, 2013
    Posts:
    48
    Man you just made my day. :) I know what I'll be doing this evening.

    Thanks, glad I was not alone in feeling addressables being overengineered and complex for what is, I assume, a pretty common use case.
     
    locus84 likes this.
  24. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    When you LoadAll for a bundle, does it return stuff in the correct order that it's in the folder or is that not something you can rely on? Sorry for poor wording.
     
  25. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    It's just assetbundle api, so I guess you can't rely on it's order. Even it does for now, I think it may be changed by unity upgrade in the future.
     
    nichjaim likes this.
  26. Paul_H23

    Paul_H23

    Joined:
    Jun 19, 2019
    Posts:
    45
    I'm a little confused about this as well. I've been working with a system that includes little to nothing in the player, and everything that might need updates and additions in remote bundles for a while. But I've hit a problem recently where, in certain global regions, the network connectivity is unstable, so relying on assetbundle downloads in order to be able to play the game can be problematic. My ideal solution would be to include all the critical bundles in the player, and not have them downloaded from the server, but still retain the ability to upload one or more of them to the server at a later date to patch the content without a new release. Is this possible? If so, how does the flow look?

    As the OP mentioned, building with included in player set seems to build all bundles as both local and remote, meaning that any effort to download all remote bundles will necessarily have to download all of them as far as I can tell, negating the value of including them in the player. If there is a methodology to allow me to embed everything in the player, and have an empty manifest in the cloud initially, that would be great, and then in the future upload a new manifest and single bundle to the cloud to allow me to patch a single bundle, or perhaps at some point a new manifest that allows me to patch 2 or three of the bundles, while still getting everything else from the embedded bundles.

    Am I missing something obvious?
     
  27. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there.

    In initialize function, it loads up all the bundles included in player. If you previously downloaded newer bundles and cached them, it tries to load newer one.

    Let's say you have same set of bundles in local and remote, as it compares their hash, you don't need to download entire bundles, the system takes newer manifest, and see the hash is already cached. If not, now it'll try to download.

    So when you failed to get manifest from remote, you can skip download function as you have configured your project include all the necessary bundles.

    Hope this helps
     
  28. Paul_H23

    Paul_H23

    Joined:
    Jun 19, 2019
    Posts:
    45
    Ahh, I think I see. So it's perfectly ok to add all bundles to the player, and upload all bundles to the server, and it'll only download if any on the server are newer. So when I make a change that requires a patch bundle, I just upload all the newly built bundles to the server, and it'll download any that have changed? Have I got that right?

    Thanks for clarifying.
     
    locus84 likes this.
  29. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Yes, exactly.
    No problem. :)
     
  30. edhumali

    edhumali

    Joined:
    Dec 14, 2020
    Posts:
    4
    Hi, is it possible to cancel a currently downloading bundle without having to edit the source? I'm looking at what's exposed at BundleAsyncOperation, but there doesn't seem to be a way to cancel it there.
     
  31. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hm... no, It can't be canceled. May I ask what you want to archive?
     
  32. edhumali

    edhumali

    Joined:
    Dec 14, 2020
    Posts:
    4
    Our app downloads large bundles (300-400MB) on demand as the user requests it (choose from a list). We'd like to give the user the option to cancel this download, for if they get impatient or want to choose another item.

    I'm guessing I can just hook into the underlying WWW object and cancelling that?
     
  33. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    I guess it won't work as the system replaces bundle while processing.
    Means a bundle can be already ready or swapped while another is downloading.
    And the problem is that the collection can be messed up as there may be missing bundles needed by dependency that's not loaded by cancelling the process...

    Let me think for a while and will let you know when I think I found a way.
     
  34. edhumali

    edhumali

    Joined:
    Dec 14, 2020
    Posts:
    4
    Oh, I see :O In the case for our app, we made sure the bundles have no dependencies on each other, so each bundle is independent. We plan to eventually have a common bundle among all of them, but the big bundles will not rely on each other's content.

    Would that still mess up the underlying systems?

    Thanks so much for your help.
     
  35. Alireza-pir

    Alireza-pir

    Joined:
    Jul 24, 2014
    Posts:
    3
    @locus84 Hello and THANK you for your great code, lets assume a scenario, i have a scene that has its own contents, i moved the scene to a folder called "Scenes" and all the content to a folder called "MinigameData"
    then I set two diffrent bundles for each of the folders and set them not to be included in build.
    what I want is to download this contents and scene and load it. they will be downloaded successfully but the scene looks like this when loaded:
    upload_2021-7-5_12-51-3.png

    can i solve this problem? could i load a scene and all its contents correctly with this package?
     
  36. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Yes that's because the shaders compiled into bundle only for the target platfrom. The Emulate in editor functionality is for those who want to see how actually it works when built in editor. If you wanna see everything, sync target platform with your development platform
     
    Alireza-pir likes this.
  37. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there, I've implemented cancel function in version 1.1.7 please check out.
    Now the functions will apply new bundles at very last so it's safe to cancel while running.

    Hope this helps.
     
    Last edited: Jul 10, 2021
    edhumali, Alireza-pir and SugoiDev like this.
  38. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Please use 1.1.8 for the test, I found a tiny bug among I've changed in 1.1.7.
     
    edhumali, Alireza-pir and Starpaq2 like this.
  39. edhumali

    edhumali

    Joined:
    Dec 14, 2020
    Posts:
    4
    Oh wow, I can't believe you went ahead and implemented it yourself :O thanks so much for this! we'll try to get it in and test it out as soon as we can! Thanks again for being awesome!!!!
     
    locus84 likes this.
  40. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    This looks promising for simple projects using Addressables, have you considered adding support for Unitask ?
     
    Protagonist and andreiagmu like this.
  41. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Good suggestion, I'll look into it. But I can't say exact date when I'll be possible.
    Thank you!
     
    andreiagmu likes this.
  42. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi guys, a new version(1.1.9) is out.

    improvement) domain reload disabled support
    improvement) compare equality interface and operators into BundledAssetPath
    fix) broken prefab links after WriteExpectedSharedBundles.

    Thanks to andreiagmu for bug reports and feature requests.
     
    edhumali and SugoiDev like this.
  43. ejx61s

    ejx61s

    Joined:
    Jan 8, 2019
    Posts:
    3
    Hello! Very Nice and simple system.
    This is an automatic translation because my English is poor.

    I am testing loading with LocusBundleSystem + SpriteAtlas AssetBundle.
    In this case, SpriteAtlasManager.atlasRequested is called twice.(Debug in Editor)

    I would appreciate it if you could confirm this behavior, as I may be using it incorrectly.
    A sample project has been prepared.

    What I want to do with the sample project

    1.I want to load the Bundle only from StreamingAssets until I agree to the Terms of Service (TitleScene > AtlasLoader).
    2.After agreeing to the terms of use, I want to download from Remote (TitleScene > Button Click).
    3.I want to execute the Remote Scene and proceed ingame (Main Scene).

    All of the above worked, but is it possible to have multiple SpriteAtlas with the same name?
    Debug.Log is "OnAtlasRequested {tag}". {tag} is "_CommonAtlas"

    https://github.com/jp-netsis/LocusBundleSystemSpriteAtlasExample

    [Project]
    Unity : 2020.3.19f1
    Locus Bundle System : 1.1.9

    [Setting]
    - Sprite Packer Mode is "Sprite Atlas V1 - Always Enabled".
    - Sprite Atlas "Include in Build" = "false"
    - Sprite Atlas Bundle Settings is Included in Player.
     
  44. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there, thank you for the detailed explanation, I'm not a native english user too, haha.
    I'll look into it btw.
     
    ejx61s likes this.
  45. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    I've created a pull request that contains recommended fixes.
    Please check.
     
    ejx61s likes this.
  46. ejx61s

    ejx61s

    Joined:
    Jan 8, 2019
    Posts:
    3
    Wow!
    Thank you for doing the research!
    It was very helpful. Thanks!
     
    locus84 likes this.
  47. IEdge

    IEdge

    Joined:
    Mar 25, 2017
    Posts:
    51
    Hi again bro!

    I was modifying a older package version and not long ago I decided to update. The problem is that it seems complicated/tedious to implement my changes to the new update, that's why I have 3 suggestions for next releases:

    - Option to build subfolders into separate asset bundles
    - Ability to modify or extends AssetbundleBuild, AssetbundleBuildSettings and AssetbundleBuildSettingsInspector classes
    - Possibility to load assetbundle from any local folder?
     
    JesOb likes this.
  48. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there!

    Those changes look viable!
    But I need some time to find ways to minimize backward breaking changes.
    I'm going to implement them step by step.(alongside my company work)

    Btw, there's different version of this library which I use in my company, I also forked and modified for my own purpose.
    It's a not that simple as this library, and still no documentation updated. But please take a look if you have some time.
    In that repo, I've already implemented multiple way of creating own assetbundlesettings. and if you like it, use discord for when you need help about v2.
    https://github.com/locus84/Locus-Bundle-System-v2

    Thanks!
     
    SugoiDev likes this.
  49. Protagonist

    Protagonist

    Joined:
    Dec 22, 2010
    Posts:
    27
    @locus84 Love your bundle system! Thanks for making it. I was not looking forward to navigating Unity's over-engineered complex solution and the many bugs people are experiencing with it.

    A couple of questions...
    1. Is it possible to build bundles locally in one project and then reference them (locally) from another project? Can I directly reference the file system where the other project built the bundles? Do I need to host a local server? Or, do I need to build and reference all bundles from the same project?
    2. I added an extension to your code (see below) to enumerate the asset names in a bundle. Would you want to add that code to your system? Perhaps you already have a way to get the names using your existing code.
    Code (CSharp):
    1.  
    2. namespace BundleSystem
    3.   public static partial class BundleManager {
    4.     public static string[] Names(string bundleName) {
    5.       if (!Initialized)
    6.         throw new System.Exception("BundleManager not initialized, try initialize first!");
    7.       if (!s_AssetBundles.TryGetValue(bundleName, out var foundBundle))
    8.         return new string[0];
    9.       return foundBundle.Bundle.GetAllAssetNames();
    10.     }
    11.   }
    12. }
    13.  
     
    Last edited: Oct 26, 2021
  50. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there, glad that you like it.

    1. Yes, you can if it contains only resources(no references, no code etc). But no, it's too fragile and not intended to use with multiple project(AssetBundles itself, and this library which built on top of AssetBundles).
    2. LGTM! I'll add it in next release.

    Thank you!