Search Unity

Asset Bundle Options?

Discussion in 'Unity Build Automation' started by jasonnk, Feb 28, 2017.

  1. jasonnk

    jasonnk

    Joined:
    Sep 30, 2016
    Posts:
    7
    What exactly does the cloud build do when you turn on "Build Asset Bundles"? I can't seem to find anything in the way of documentation on that section of the configuration.

    Does it also offer an option to download the generated asset bundles through the UCB web interface or would I have to hook in a post-build script to transmit them somewhere else?
     
  2. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    By default it builds the asset bundles to an AssetBundles/ folder. You would then either need to enable "copy to streaming assets" to have them included directly in the build or write a custom post-build script to push them somewhere for hosting.
     
    jjmontes likes this.
  3. jasonnk

    jasonnk

    Joined:
    Sep 30, 2016
    Posts:
    7
    Thanks, does it just build all the asset bundles and variants it can find through AssetDatabase.GetAllAssetBundleNames()?
     
  4. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    Yes, exactly. Anything marked for inclusion in bundles in the editor should get automatically built.
     
  5. davidncumming

    davidncumming

    Joined:
    May 22, 2017
    Posts:
    2
    Hi Danny,

    I've tried setting a Bash "Post-Build Script" to do as you suggested, using curl to upload my asset bundles to an Amazon S3 bucket. It executes correctly from the Unity project folder on my local machine but not on Cloud Build. The problem is actually navigating to or accessing the AssetBundles directory on the remote machine.

    Executing the command pwd in my post build script tells me that I am in:

    /BUILD_PATH/.mason/buildpacks/unity/bin

    Executing ls -a gives me the directory listing:

    .
    ..
    compile
    defaults
    detect
    manifest
    release
    validate_target

    This is a surprise because having set the Post-Build Script path to AssetBundles/myscript.sh and have it successfully execute I would expect that it is running within a Unity project folder, or at least a folder with an AssetBundles directory inside it.

    Then for example executing the command cd compile gives me the error:

    cd: compile: Not a directory

    After spending longer than a day writing exploratory scripts to poke around inside the Cloud Build environment (e.g. navigating to /BUILD_PATH/ and then attempting to navigate to the destination folder /BUILD_PATH/mycomany.mygame.android-develop-ab/.build/), I'm no closer to finding the AssetBundles folder, or anything that looks like a Unity project folder. Please help! This stuff seems to be entirely opaque and undocumented.

    I also tried using an Editor script method but apparently the Unity AWS SDK only runs in game mode, not in the editor, so it seems like there is no easy option there.

    Thanks, David
     
  6. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    The post-build script is passed three parameters:
    1. export_directory: directory the unity build process exported to
    2. output_directory: final output directory (where the final build artifacts get copied to)
    3. platform: platform currently being built for
    You could navigate up a few levels from the output_directory to get back to the project directory.

    You could also just use some bash magic to get the directory of your script, ex: https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
     
  7. davidncumming

    davidncumming

    Joined:
    May 22, 2017
    Posts:
    2
    Thanks for the reply Danny.

    I'm sure your advice would have solved my problem, but I ended up writing a C# post build method which is working fine.
     
  8. jtkerste

    jtkerste

    Joined:
    Dec 28, 2016
    Posts:
    2
    David, regarding the post build method you ended up implementing, were you able to find a way to utilize the AWS SDK within a static function or did you utilize some other method of posting to S3?

    I am looking to have AssetBundles put in an S3 bucket post cloud build.

    Thank you.
     
    rebelincontrol likes this.
  9. rebelincontrol

    rebelincontrol

    Joined:
    May 19, 2015
    Posts:
    30
    Also looking for a solution to this.
     
  10. henkjan

    henkjan

    Joined:
    Aug 1, 2013
    Posts:
    146
    I'm also trying to find the AssetBundle folder but it the output_directory and platform are no longer supported. The only thing I get in my post export script is the export_directory.
    I have searched there but can't find the AssetBundle folder.
    Where is the folder with the asset bundles located? Is there any documentation about this?

    It sames very obvious that people want to store there asset bundles on a webserver for the games to use :)
     
    tonialatalo likes this.
  11. Mouldi

    Mouldi

    Joined:
    Feb 23, 2013
    Posts:
    20
    Hi Danny,

    How can I know when the asset bundle is built and copied to the streaming folder? is there a callback method?
    And how can I get a reference to the built asset after it's built?

    Thank you,
    Mouldi
     
    tonialatalo likes this.