Search Unity

Simpler Alternative to Addressables.

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

  1. Aoedipus

    Aoedipus

    Joined:
    Jan 31, 2019
    Posts:
    25
    Thanks! It may also be worth mentioning that webGL is the delivery platform, which seems to be raising some other issues with remote path setting and compression support.
     
    Last edited: Oct 27, 2020
  2. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    It looks like a bug and I fixed it.

    https://github.com/locus84/Locus-Bundle-System/releases/tag/1.0.9
    Please update to latest version and check again.

    Regards!
     
  3. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there I'm working on AssetReference like functionality. It will provide simpler way to link/select an asset to actual load path, but I I'm sure you still need to code to load/release from them.(actually, you can disable in-time memory release feature and stick with Resources.UnloadUnusedAssets if you want to write less code.)

    Regards.
     
  4. IggyZuk

    IggyZuk

    Joined:
    Jan 17, 2015
    Posts:
    43
    Hello, is there a way to avoid the lag spike when loading and instantiating a large asset for the first time? I tried an async load + instantiate but it still has the same lag.

    Pretty much the same as: GameObject.Instatiate(Resource.Load(...))

    Code (CSharp):
    1. public static void LoadAndInstantiateAsync(string assetName, MonoBehaviour context, Action<GameObject> onComplete)
    2. {
    3.     IEnumerator DoLoadAndInstantiate()
    4.     {
    5.         using (var loadReq = BundleManager.LoadAsync<GameObject>("LocalAssets", assetName))
    6.         {
    7.             yield return loadReq;
    8.             var instance = BundleManager.Instantiate(loadReq.Asset);
    9.             onComplete?.Invoke(instance);
    10.         }
    11.     }
    12.  
    13.     context.StartCoroutine(DoLoadAndInstantiate());
    14. }
     
  5. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there, are you testing with editor? For now, async loading from editor with AssetDatabase actually use synced version, If you build and test with actual device, there'll be less hiccup.
    I planned to improve this in the future.

    Thank you!
     
  6. IggyZuk

    IggyZuk

    Joined:
    Jan 17, 2015
    Posts:
    43
    Right, I see!

    It's definitely better in the build, although there is still a tiny spike the first time an instantiation happens. Is there anything I can do about this?

    Memory management wise – let's say you have 100 different enemy types. Would you recommend putting them in different asset bundles or all into one? Can the bundle be partially unloaded?

    Thanks for the help!
     
  7. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    1. It looks like a shader is compiled when you instantiate your first object.
    You can make a base bundle that only holds tha shaders with cube, instantiate it first.

    2. It can't be unloaded partially, keep it split if it's not too tiny.

    Regards!
     
    andreiagmu and IggyZuk like this.
  8. IEdge

    IEdge

    Joined:
    Mar 25, 2017
    Posts:
    51
    Simple and easy to setup, synchronized API, Load/Unload, just that I need for my project!

    But I have 2 problems:

    1. In the sample scene when I load the cube, it has reference problems with the material shader (pink color), and same for sky of the loaded scene.

    2. I have the following folder structure: Pic.png
    When I load "Front/MySprite" I get a error, I have tried with "Spritesheets/Front/MySprite" but is the same. What I doing wrong here?

    3. It's possible to load a bundle from a custom location in runtime?
     
  9. locus84

    locus84

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

    1. That's because shader is stripped only for target platform, if you test it on your device or disable "Emulate In Editor" option, you can see proper result.
    2. Can you test with normal gameobject? or send me a zip file that I can reproduce?
    3. No, the remote url is saved into local manifest. you can make modification on your own but currently I don't have any plan on that functionality

    Thank you!
     
  10. Kultie

    Kultie

    Joined:
    Nov 14, 2018
    Posts:
    48
    @locus84
    Are there anyway to delete downloaded bundle to free device storage?
    Currently I'm using Addressable but the workflow is kinda wonky so I'm look for alternative.
    Testing your solution I think it's gonna work better than addressable in some aspect
     
  11. locus84

    locus84

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

    It's already handled automatically,
    When you download assetbundles, the download function bump assetbundles, and clean cache except using bundles.
    https://github.com/locus84/Locus-Bu...9003bbe40ccf34b/Runtime/BundleManager.cs#L380
     
  12. Kultie

    Kultie

    Joined:
    Nov 14, 2018
    Posts:
    48
    So it's handle automatically right? And from my understanding the system will remove bundle cache base on that bundle's ref count right?
    How do I manually remove a bundle?
     
  13. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    1. When downloading -> Remove not using bundles in cache.
    2. When a loaded asset's reference count hits zero -> Replace assetbundle loaded in memory to reduce memory.
    3. You better not to unload yourself as it's managed by system. if you need to free some memory regardless of reference count, use Resource.UnloadUnusedAssets
     
  14. Kultie

    Kultie

    Joined:
    Nov 14, 2018
    Posts:
    48
    Thanks for your information.
    But I don't need to free memory that application use, I need to remove the bundle that downloaded and saved as cache on device storage. Even that bundle is not in using or refcount is > 0
     
  15. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    When you call download assetbundle function,
    There's arguments called manifest, and subsetnames.
    in manifest, there are all bundles you need to keep, and subsetnames(if non-null) will be subset of those bundles that need to download among those in manifest. reason why this is separated is that most case, removing latest bundle from cache is not expected as user must download that file later on.

    In short, if you remove a bundle you don't need from manifest, download function will remove that bundle from cache either.
     
    Kultie likes this.
  16. Kultie

    Kultie

    Joined:
    Nov 14, 2018
    Posts:
    48
    Thank you very much for this information. Imma test it when I go to work.
     
  17. IEdge

    IEdge

    Joined:
    Mar 25, 2017
    Posts:
    51
    Sorry for delay. Sure! Here is a portion of my spritesheets folder.
     

    Attached Files:

  18. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Thank you for your resources, I've used that for testing, and fixed everything.
    A new version is out with related fix!

    Regards.
     
    IEdge likes this.
  19. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    228
    This is really starting to look more and more attractive. Is this library generally production-ready, in your mind? Are there any major issues, known bugs, or "gotchas" that it comes up short on for actual production use-cases, etc?

    Am surprised to see not even a single issue on the GH repo (despite having a solid following and numerous forks/plenty of people looking at it); is it generally just working well for those of you who have tried it, assuming there are some of you out there?

    Context -- Why Addressables is Killing Us
    We're basically at the point where Addressables is costing us a fortune. It's too unstable, the documentation is basically auto-generated API docs with very little value add and few [if any] improvements, release management & QA is abhorrent, and the communication is simply MIA.

    Case-in-Point:
    We updated from 2019.4.14f1 to 2019.4.15f1 -- typical minor version bump of an LTS ["stable"] release stream -- only to find that Addressables is forcibly updated to a newer version that completely breaks our game. Worse, we're seemingly unable to downgrade the package, the new editor version truly forces the pkg version back up again after manually downgrading it. Oh, and the breaking changes -- they basically aren't documented or explained, and we still can't make heads or tails of the intended usage (see this thread). @unity_bill @Shaunyowns

    Is this Stable & Production Caliber?
    As I said, this is increasingly looking like a potentially perfect route to go IMO -- especially when contrasted against the state of Addressables today! This looks surprisingly polished, seems to have all the things we actually need (which isn't much, just basic loading & the ability to do basic memory management -- we don't want any UIs or merge-conflict-prone meta-data, etc)... Is it too good to be true, or worth a shot?

    @locus84 Are you using this in any production capacity currently? Do you plan to continue supporting it? Are you open to PRs and/or to taking donations [or similar] to continue maintaining it? Don't feel pressured to say "yes", not asking for you to make a commitment or to do any free work -- just hoping to better understand your relationship to the library's code. :)
     
    andreiagmu and IEdge like this.
  20. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Glad to hear that!(Not glad to see Addressable is still not quite user friendly...)

    Reason why there's no issue in github, is that I actually didn't provide any issue template or something,
    and people just asking me here as there's no discord, no community. But it looks fine as whenever I do some work on the library, the thread bumps up and many other people can see it.

    Initial version of this library has been used in my previous company.(still on the market)
    Current version is used by my old colleagues those who made up their mind to make their own games.
    And they have released at least two game so far without problem.
    I already imported this library for my next company project.

    I don't plan to receive any donates from others for now. I want to take advantages of opensource.
    Thanks to people in this thread, this library is keep getting better.
    Maybe I might open donates when I don't need to update this library for myself(retired, moving to other engine.. etc)

    This library does provide simpler way to use Assetbundle compared to Addressable, but is not fit-for-all kind of thing.
    I'll keep develop this project but it will be remain simple. If you want more complex functionality for your own project, I always recommend forking the repo. Making PR is great but it can be declined if it looks over-complex.

    Regards.
     
    andreiagmu and Kazko like this.
  21. St-Aaron

    St-Aaron

    Joined:
    Oct 7, 2020
    Posts:
    11
    Has anyone tried this library with the Unity Cloud Builder? It's proven to be a pain to use Addressables with UCB (or just without UCB) and this looks like a more user friendly alternative!
    I'll test it out today and try to get it working with UCB, but was wondering if anyone else already had some gotcha moments that I should be aware of :)

    Edit: did a pretty simple test with remotebundle on AWS S3 and it seems to work smoothly, including changing to a new RemoteBundle without rebuilding on UCB :D
    This might seem pretty straightforward perhaps, but for a Unity newbie who has been breaking his sanity on addressables, this has been a very refreshing smooth ride!

    Thanks for the amazingly smooth process so far!
     
    Last edited: Dec 4, 2020
    locus84 likes this.
  22. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Haven't tried that, but great to know it works for you.
    Even it's hard to test for me, let me know if there's something wrong.
     
    Last edited: Dec 5, 2020
  23. St-Aaron

    St-Aaron

    Joined:
    Oct 7, 2020
    Posts:
    11
    Found something of a small bug/issue, where building an app with locus-bundle-system included, but without having done any building of the Local bundles results in in an
    IOException: Failed to Copy File / Directory from '/development/work/.../test-app/LocalBundles/Android' to '/development/work/.../test-app/Assets/StreamingAssets/localbundles/'.

    Building the Local bundle fixes this, but I couldn't find a mention that this was necessary pre app-build (unless I overlooked it)
     
    locus84 likes this.
  24. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Thank you for the report!

    I think that's caused by build processors of the library.
    Maybe I can just make a simple warning for that situation that indicates there's no bundle information.
     
    Last edited: Dec 10, 2020
    IEdge likes this.
  25. St-Aaron

    St-Aaron

    Joined:
    Oct 7, 2020
    Posts:
    11
    Hi, got another question, of which I'm not sure whether it's a bug or not, but when the DontDestroyOnLoad _BundleManager gets created, it references 2 scripts, Bundle Manager/Bundle Manager Helper and Bundle Manager/Debug Gui Helper, but neither of those seem to be present:
    Screenshot from 2020-12-16 15-55-14.png

    Do they need to be further initialized or something? This behavior happens in the 2 projects I've tested the BundleManager in.
     
  26. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there, that's intended, those scripts do not have explicit files thus they can't be attached/found in editor except doing it programmatically. You can easily find their symbols inside runtime scripts, and you'll find there's actually very little functionalities indside.

    Regard!
     
  27. St-Aaron

    St-Aaron

    Joined:
    Oct 7, 2020
    Posts:
    11
    Ah ok, that makes sense, thanks for the fast reply!
     
  28. locus84

    locus84

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

    I've added a lot of functionalities/improvements in this version(in my opinion).

    Even though I've done testing those new functionalities,
    please check out and let me know if there is something wrong.

    I'll actively fix errors for 1~2 weeks from now on!
    Your feedback always helps!!!!
     
    Last edited: Dec 20, 2020
    andreiagmu, Starpaq2 and Raghavendra like this.
  29. troyman34

    troyman34

    Joined:
    Apr 25, 2013
    Posts:
    5
    Hello! I was wondering if it was possible to load sub assets, or in our case sprites from a spritesheet, as you can with the Resources API. Example: Sprite[] sprites = Resources.LoadAll<Sprite>("folder/spritesheet");
    Thanks.
     
  30. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hi there.
    I think that is possible(not atm).
    But whenever you load those subassets, in my system actually, it'll add corresponding reference counts to that bundle. And they all need to be released manully or by garbage collection to release the origin assetbundle.

    Is that okay?, can you elaborate how you need those assets ?
     
  31. troyman34

    troyman34

    Joined:
    Apr 25, 2013
    Posts:
    5
    yes that makes sense that it would add the corresponding ref counts. In my situation we have multiple sprite sheets for different types of armor, and if we want to change the armor on the character we would load the spritesheet with the Resources.loadAll<Sprite>(path) method, which gives us an array of all the sprites in our spritesheet, and use sprites appropriately. I also ran across the AssetBundle.LoadAssetWithSubAssets method in unity docs. I have never personally used it, but it sounds like the functionality I am looking for. https://docs.unity3d.com/ScriptReference/AssetBundle.LoadAssetWithSubAssets.html
     
  32. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hey,
    I've added the api you requested.
    named 'LoadWithSubAssets<T>'
    Please apply the lastest version(commit I mean) and check it out.
    If there's no problem, it'll be added to the next version.

    Thank you!
     
  33. troyman34

    troyman34

    Joined:
    Apr 25, 2013
    Posts:
    5
    Wow thanks! It appears to be working as expected!
     
    Last edited: Dec 30, 2020
    locus84 likes this.
  34. troyman34

    troyman34

    Joined:
    Apr 25, 2013
    Posts:
    5
    Hey! So I may have found a small issue in the TryGetBundleNameAndAssetPath() method in the AssetbundleBuildSettings.cs file. On line 71, I think you may have wanted something like the following instead:

    if (!setting.IncludeSubfolder && partialPath.IndexOf('/') > -1) break;
     
    locus84 likes this.
  35. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Oh yes!
    Thank you for pointing out!
    Applied to the latest commit!
     
  36. troyman34

    troyman34

    Joined:
    Apr 25, 2013
    Posts:
    5
    Hey, I found some spots in the BundleManager.Api.cs file where you may want to put some null checks. After any asset is loaded from a bundle, the found asset is then immediately called with the TrackObjectInternal() method. There possibly should be a check to see if the "loadedAsset(s)" variable is not null before running it through the TrackObjectInternal() method, since not doing so can result in errors. I guess I am using the load methods with the expectation that if I gave it an incorrect bundle/asset pair it would just return null and not error out as it is.
     
    locus84 likes this.
  37. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Actually, I haven't run into that kind of issue as I always load properly in my project.
    But I see what you mentioned is more Unity-like way.

    I've added some fix on lastest commit
    1. Load<T> gives null if loaded object is null
    2. LoadAsync<T> gives finished BundleRequest<T> holds null if loaded object is null
    3. LoadWithSubAssets<T> gives you empty array if nothing to load or could not found bundle.
    4. Added helpful Exception throwing inside Intantiate functions.

    Thank you for improving the library.
    Hope this can help you.
     
  38. Klausini

    Klausini

    Joined:
    Feb 19, 2010
    Posts:
    37
    Hello Locus84,

    after cursing on Addressables for nearly 2 months now this looks extremely promising. Everything is way more logical and clear. During my test everything local runs like a charm, but when I try to download from the CDN I always get a "Network Error". I know I am doing something wrong, but I simply have not found a way to fix it.

    So here is my manifest:
    https://locusbundletest.s3.eu-central-1.amazonaws.com/StandaloneWindows/Manifest.json

    What do I need to enter into the remote location? My assumption was
    https://locusbundletest.s3.eu-central-1.amazonaws.com/

    How can I debug my error? I am obviously no expert on this. The manifestReq.ErrorCode simply says "Network Error".

    If you decide to make this a full commercial product on the asset store I am damn sure not only me would buy it! In our face Unity!
    Many thanks!
     
    locus84 likes this.
  39. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Great to see you like this, did you run local bundle build before building actual client?, the cdn address is encoded into Manifest.json, so local bundle would contain that info even there's no actual assets to build.

    You can always debug yourself, by generating csproj files of your packages(inside preferences I guess).
    And you can enable 'Emulate In Editor' option to actually use assetbundles from remote.
     
  40. ExtraCat

    ExtraCat

    Joined:
    Aug 30, 2019
    Posts:
    52
    I started looking for alternatives to Addressables after witnessing multiple times how they behave differently in editor and in the build itself for no apparent reason, greatly increasing debugging time.

    So far your solution works flawlessly, and I have to say it also has way better documentation too. If you ever decide to sell a pro version on the store, count me in as a buyer.
     
    andreiagmu, Starpaq2 and locus84 like this.
  41. Kazko

    Kazko

    Joined:
    Apr 2, 2014
    Posts:
    82
    @locus84 where the hell is your donate button? Wow, this seems very cool.

    One thing I'm really missing and what I actually loved about Addressables was the AssetReference - specifically that I did not need to track where the asset is located. Once the link is made, the asset can move freely and the link updates. It's crucial for my stage of development when designing highly modular systems, the asset structure is always evolving.

    I know you mentioned that you were working on something similar for your package. My question is just about your expected feature set, if this feature will also track linked assets so that my references wouldn't break.

    No pressure, just trying to make some decisions based on expectations of future functionality. Thanks a lot!
     
    locus84 likes this.
  42. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    Hello, whenever I enable the emulate in editor mode to closer test what a build of the game will be like, the unity fog seems to break and not work properly. Does anybody have any idea what might be causing the problem?
     
  43. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    That's because shader is stripped only for target platform, if you test it on your device or disable "Emulate In Editor" option, you can see proper result.
    Or you can sync output platform with editor, temporary.
     
  44. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    Hello, I think I might add the functionality in the future, but the tradeoffs are first loading time, and memory for additional mapping, it'll take time until I found best solution. One thing is that there'll be toggle for the option for those who prefer less memory overhead and strict asset outline over convenience.
     
    andreiagmu and Kazko like this.
  45. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    Thank you for responding! When creating an actual build, the fog seems completely absent but when I ensure that the fog shaders are included (used this link for instructions: https://support.unity.com/hc/en-us/...bling-the-Fog-in-a-built-game-is-not-working-) then the fog does seem to be included but is noticeably broken and doesn't look the same as when in the editor with 'Emulate In Editor' disabled. Is there something I'm doing wrong or does this problem not even have anything to do with the bundle system?

    EDIT: I'm randomly instantiating some prefabs that are grabbed through the bundle system at runtime and those seem to be the objects that are not affected by the fog for some reason. The other objects seem to properly be obscured by the fog.
     
    Last edited: Jan 31, 2021
  46. Starpaq2

    Starpaq2

    Joined:
    Mar 14, 2013
    Posts:
    77
    https://github.com/locus84/Locus-Bundle-System/blob/master/Runtime/AssetbundleBuildManifest.cs#L114

    I believe should be changed to :
    Code (CSharp):
    1. return resultDic.Values.ToList();
    This way the asset bundles can be downloaded by string.

    QUICK TIP FOR THE COMMUNITY
    if anyone needs to download specific bundles you can add a ienumerator list to as a parameter like so:

    Code (CSharp):
    1. IEnumerable<string> bundleList = new List<string>() { "mybundle_name"};
    2.        
    3.         //Download selected bundles linked to the manifest
    4.         var downloadReq = BundleManager.DownloadAssetBundles(selectedManifest.Result, bundleList);
     
    andreiagmu and locus84 like this.
  47. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
  48. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    That's weird, have you tried without bundle system? I mean, fog and object from just resources folder.
    Or can you try force-rebuild tick on before you build?

    I think if some of them works, it maybe a problem of the fog shader or the object shader, or maybe clipping/lod problem.
     
    Last edited: Jan 31, 2021
  49. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    46
    Hey! Sorry to bother you about this again, but it seems that the materials of the objects within the loaded prefabs develop some kinda issue which causes the fog not to be rendered on them. I know this because whenever I reset the object material to it's intended material during runtime via the editor then the fog shows up on the object again. I was wondering, is there a way to do this via script, I tried to write something that would reset the materials but it always just set the materials to some instance of the intended material and didn't solve the issue. How do I get a reference to the original material asset like when changing materials through the editor? I understand if this isn't your area of expertise, just thought I'd ask if you knew.
     
  50. locus84

    locus84

    Joined:
    Mar 30, 2011
    Posts:
    119
    You can replace shaders according to it's name whenever you load from bundle by script.

    But what I recommend is finding the reason first.
    Without knowing the reason, workaround will be just a temporal fix.
    And if you keep testing in your main project, it'll confuse you as well as takes more testing iteration.

    Create an empty project, import fog and very minimal asset.
    Try to reproduce the issue.
     
    nichjaim likes this.