Search Unity

Addressables + Cloud Build: Updating remote resources

Discussion in 'Addressables' started by lloydv, Sep 9, 2019.

  1. lloydv

    lloydv

    Joined:
    Sep 15, 2015
    Posts:
    14
    I'm new to Addressables and working on a project that builds with Cloud Build.

    I was happy to find Addressables already integrated into the dashboard, so I turned the switch on and on my next build there was a package with the remote ServerData to upload. Awesome!

    However, in the downloaded zip file there is also a Library/com.unity.addressables/StreamingAssetsCopy/aa/iOS folder and I don't know what the contents are intended for. Is there some documentation on this somewhere?

    Also I am very vague on how remote assets can be updated when using Cloud Build, because I don't see anywhere to create or select the magical '.bin' file like in the demo videos.

    I hope someone can share their expertise or experience. Thank you.
     
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    268
    Here's a tutorial may help in general https://forum.unity.com/threads/demo-tutorial-for-remote-hosting-using-amazon-s3.724022/

    It's not well documented. Just known they're settings file (where to load catalog) and local catalog (to load local content) is good enough.

    You may possible to upload the bin file and other remote assets of RemoteBuildPath, to your content server in PostExport method of Cloud Build (using Sync IO). There's no example code so far, so please share if you reach there.

    You may also fire a ticket to Unity Cloud Build team to ask them adding the feature to download content from RemoteBuildPath, like another zip file from the build panel, or the a link in webhook.
     
    lloydv likes this.
  3. lloydv

    lloydv

    Joined:
    Sep 15, 2015
    Posts:
    14
    @Favo-Yang Thank you for the info, now I have a little more direction to work in.

    I understand they're settings files, but the fact that they're included with the bundle build makes me think I need them for something. Am I supposed to manually put these files back in the library folder on my machine, maybe?

    So far I've got my addressables built on Cloud Build, hosted remotely, and loading correctly in an iOS app. Next step is to try and update remotely, and for that I need the bin file. I've already got a post-build shell script set up that uploads the ipa to Deploygate, so hopefully this won't be too headache-inducing...

    Will post back here when I've tried a few things.
     
  4. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    268
    Only if you intend to use those cloud build bundles (local / remote) in your local development (or share with other devs to save their build time). In such case, you will need sync the setting files to locate remote catalog. Depends on whether you have local contents, and other details, those setting files may have no change during build time and can be safely committed into repo. See this thread #7, #8 for details.

    The bin file will be located at the RemoteBuiltPath. However it only required by preparing a content update, and building for content update. In such case you will need download the saved bin file from previous build, the default addressable build panel won't be useful for that. You need write a custom script as PreExport hook.

    However I wonder if you really need the *content update* thing. It's a process designed for preparing incremental content build, for public releases. As you described, the major use case is testing purpose through Deploygate, you won't get much benefits I guess.
     
    Last edited: Sep 9, 2019
  5. lloydv

    lloydv

    Joined:
    Sep 15, 2015
    Posts:
    14
    Got the bin file using a post-build .sh script. Here's how:

    Code (CSharp):
    1.  
    2. # Unity Cloud Build manifest file location
    3. UCB_MANIFEST=$WORKSPACE/Unity/Assets/__UnityCloud__/Resources/UnityCloudBuildManifest.json.txt
    4.  
    5. # log its contents
    6. cat $UCB_MANIFEST
    7.  
    8. # extract the build number using regex
    9. CLOUD_BUILD_NUMBER=$(grep -o '"buildNumber":"[^"]*' $UCB_MANIFEST | grep -o '[^":]*$')
    10.  
    11. echo "Cloud build number: $CLOUD_BUILD_NUMBER"
    12.  
    13. # Addressables bin file location
    14. ADDRESSABLES_BIN=$WORKSPACE/Unity/Assets/AddressableAssetsData/iOS/addressables_content_state.bin
    15.  
    16. # Print byte count (for proof that the file exists in the log)
    17. wc -c $ADDRESSABLES_BIN
    18.  
    19. # Send addressables bin file to firebase function
    20. curl \
    21.   -X POST \
    22.   -H "Content-Type: multipart/form-data" \
    23.   -F "buildNumber=$CLOUD_BUILD_NUMBER" \
    24.   -F "file=@$ADDRESSABLES_BIN" \
    25.   https:/XXXX.cloudfunctions.net/my_upload_function
    26.  
    The bin file and build number are submitted to a custom firebase function that simply saves the file to firebase storage so I can download it when I need it (when I want to update remote addressables for a production build).

    Two things to note:
    • I've hardcoded the iOS path, will make it dynamic later
    • There's surely a better way to write that json-parsing regex

    It would be really nice if there were ANY documentation at all on shell scripting for Unity Cloud Build. Even something as simple as getting the cloud build number requires a lot of effort and snooping around in the dark. I pretty much had to hack this together over about 20 build iterations (partly just because I suck at shell scripting), the last few of which took almost 2 hours each because the build manifest json doesn't even exist when the pre-build script is run, so I had to run the build to its completion to test the result.

    Alternatively, yes, I could have written a c# script that does the same thing, but I like the idea of isolating my build logic from the rest of the codebase. It's also a heck of a lot cleaner to curl a file from the shell than to use a UnityWebRequest.
     
    Favo-Yang likes this.
  6. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    268
    Thanks and you may want to cross post on cloud build sub-forum.