Search Unity

Integrating Asset Bundles into my build pipeline

Discussion in 'Asset Bundles' started by hofstudios, Jul 28, 2019.

  1. hofstudios

    hofstudios

    Joined:
    Jan 19, 2018
    Posts:
    3
    I've been working on getting asset bundles working for my console builds but am now trying to integrate it into the standalone builds as well and I've run into some confusion on my part (i think). Or at least i feel that the Unity documentation is very vague on this...

    Some details about the project:
    developed on OSX
    supports Windows x86, OSX and Linux 64
    uses the Super Unity Build asset to create builds for Steam, GOG and DRM free (8 builds total)
    Super Unity Build has a pre-platform processor where I am building each set of bundles that are needed before the build is created

    So here's the confusion:
    I use this code to load each bundle at runtime
    var bundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, name));

    My working assumption: only the assets for each platform should be in streaming assets before I build for that platform. This is unclear in the documentation. Using streaming assets is problematic for me for a number of reasons (can't play in editor without OSX assets, need to keep copying assets back and forth, etc)

    Is there a folder where i can put the per platform built assets and have them included in the build instead of using streaming assets?
    How can i reference this path when i am calling LoadFromFile?
     
  2. jhughes2112

    jhughes2112

    Joined:
    Nov 20, 2014
    Posts:
    70
  3. hofstudios

    hofstudios

    Joined:
    Jan 19, 2018
    Posts:
    3
  4. jhughes2112

    jhughes2112

    Joined:
    Nov 20, 2014
    Posts:
    70
    I wrote the AutoBuilder asset, which accomplishes a similar thing. I don't put bundles in the build... they don't belong there, typically, as they are normally hosted on CDN. If you have them built into the final product, they can go in Streaming, but generally they go somewhere outside the Assets/ folder, so you can upload them. Mine go in a folder called /Build/ parallel to /Assets/, by default. If you plan to download bundles at runtime, they won't work in Streaming because that's a read-only folder on some platforms, or not available at all. So anything you want to persist from run-to-run, you drop it there, in the Persistent Data Path.
     
  5. jhughes2112

    jhughes2112

    Joined:
    Nov 20, 2014
    Posts:
    70
    Seems I may have misunderstood what you were asking for. While running in the editor, if you expect bundles to already be there, you have to swap whatever version you have in those folders. That only makes sense, especially if you change platforms, you will have to change what files are present. Maybe you should consider putting a short platform descriptor in the bundle name, so you can have them all physically present while in the Editor, but only wrap up the ones you really want into the builds when you produce a build?
     
  6. jhughes2112

    jhughes2112

    Joined:
    Nov 20, 2014
    Posts:
    70
    For what it's worth, AutoBuilder writes the hash of the contents of each bundle into the name, so it allows you to change what version you're running against, or what platform you're running against, and it doesn't care. It just downloads anything that is missing according to the manifest and runs. Makes that kind of issue go away, even in the Editor.
     
  7. hofstudios

    hofstudios

    Joined:
    Jan 19, 2018
    Posts:
    3
    thanks for the response. this is a slightly different use case since i am making these bundles for local use on the game consoles. I'm going to assume they belong in streaming assets in that case.