Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Asset Bundle Dependencies

Discussion in 'General Discussion' started by CG_Echtzeitschmiede, Jun 4, 2016.

  1. CG_Echtzeitschmiede

    CG_Echtzeitschmiede

    Joined:
    Feb 19, 2015
    Posts:
    93
    Hi,

    I am a little confused right now how to correctly split up my content into asset bundles. We are working on a puzzle game with many different levels. Each level will be its own asset bundle.

    Some of the content of these levels will be identical across all levels, specifically the GUI with all of its icons and textures. I want this content to be installed directly with the base game.

    So I was planning on taking the .unity file of each level and assigning it to its own asset bundle. If I do this, I believe that Unity will collect all dependencies (among others, the GUI with its icons) and also put that into the bundle. So how can I have this stuff be part of the base game instead? Well, technically I think it would be in the base game, but it would also be in every single bundle. I want it to be ONLY in the base game and have all asset bundle scenes use these assets from the base game.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    You should probably assign the common stuff - GUI, icons and whatever else is needed across all level, into its own asset bundle (name that "Common" for example).

    This asset bundle can be delivered directly with the game package itself (not as a separate download). All other asset bundles (each for its own level) will reference assets that are contained in the shared (common) asset bundle. This bundle will be automatically loaded when the game is started so it's accessible to all levels that need it.
     
  3. CG_Echtzeitschmiede

    CG_Echtzeitschmiede

    Joined:
    Feb 19, 2015
    Posts:
    93
    Thank you very much, I see what you're saying. Just one more question, how can I make sure that this common asset bundle is included in the APK?
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    You can either place that under a Resources folder, or under StreamingAssets.
    Both will get included into your game build.
     
  5. Deleted User

    Deleted User

    Guest

    You can also use a custom text file format and serialize your levels to avoid using asset bundles.
     
  6. CG_Echtzeitschmiede

    CG_Echtzeitschmiede

    Joined:
    Feb 19, 2015
    Posts:
    93
    I see, thank you so much for your help!

    That sounds like an excellent workflow, however in the case of our game every level has its own custom meshes and textures, which is why we use asset bundles to split the data up into lots of smaller downloads.
     
    Deleted User likes this.
  7. CG_Echtzeitschmiede

    CG_Echtzeitschmiede

    Joined:
    Feb 19, 2015
    Posts:
    93
    I have a followup question now. Our levels will all have a prefab that contains the GUI and a custom script. The parameters for this custom script will be individually set for each level.
    If I now put this entire prefab into its own asset bundle as discussed, will all levels correctly refer to that same prefab, even though some of the parameters on their version of the prefab are different?

    The reason why this is important is so that we can later update that one prefab with new functionality in the base installation, and all DLC levels will automatically use that new prefab (but retaining their changed parameters), rather than needing to be updated themselves.
     
  8. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    This should be fine - all levels should be marked as their own asset bundle, and the referenced prefab should be placed in its own asset bundle.

    In this setup, all scenes will contain a reference to that prefab which should be loaded from its own asset bundle. All scenes will save their own values for this particular prefab so you should be good to go.
     
    CG_Echtzeitschmiede likes this.
  9. CG_Echtzeitschmiede

    CG_Echtzeitschmiede

    Joined:
    Feb 19, 2015
    Posts:
    93
    Ok perfect, thank you so much for confirming that this should work!