androidunity-game-enginein-app-purchaseaddressables

Delivering downloadable content to Android application in Unity (loading with Addressables)


I have a rhythm game that I am almost finished working on but have hit a bit of a snag. We have an in-app store where users can purchase additional "song packs" for money. These packs contain song files (text asset), song banner images (png) and the songs themselves (mp3). This data is stored on our server, and the Unity app communicates with the server after a successful purchase is made. The server script validates the purchase via the Google Play Purchasing API (with the purchase token) and then if its valid, downloads the zip file of the data and extracts it into the Unity app. This part is working great.

However, I seem to not understand in what format I need to have the content or where exactly to put it. Furthermore, my game makes use of Addressables tags to load data between scenes. This works, but I am not sure how exactly I would handle this for downloadable content. Can I create new addressable tags via the API at runtime? I want to be able to add additional downloadable content to the app without needing to update the base games Addressable information. Is this even possible?

My main questions are:

  1. How do I deliver my downloadable content? Do I need to package it in some type of Asset Bundle? Would this keep the import settings like audio compression that I set in Unity?

  2. What folder should I extract the downloaded content on Android? StreamingAssets?

  3. Can I create Addressable tags at runtime? Is this possible and is this a good idea?

Thank you for the help!


Solution

  • I would rather only code one core URL where your app when it is started can find and download the Addressables content catalogue! This allows you to fully add and remove entire Addressables, groups, tags etc without ever needing to rebuild your app. You could e.g. give each of your root objects a certain label (the same for all) then you can basically load the catalog and show the user all existing tagged results without immediately loading them .. see LoadContentCatalogAsync


    How do I deliver my downloadable content

    You need to build your Addressables via the group window and then simply copy the entire content catalog (JSON and hash) and the resulting individual Addressables (usually one per group) onto your server where your app can access and download them.


    This way you can basically even have two complete separate Unity projects, one for building the content, one for the actual app.

    You only need to be sure that both projects have the same code base used by your addressables and that all required dependencies are either in the projects or within the Addressables.

    See Loading from Multiple Projects