Search Unity

Question How to load multiple AssetBundles at the same time

Discussion in 'Asset Bundles' started by unity_tk6WK8qP7H-HHQ, Mar 16, 2021.

  1. unity_tk6WK8qP7H-HHQ

    unity_tk6WK8qP7H-HHQ

    Joined:
    Oct 16, 2020
    Posts:
    1
    I have this code below where the game loads the resources from the AssetBundle called "level" but the Bundle is already 3.5GB and I can't keep updating this Bundle and let people download 3.5GB everytime there is something new, so I was thinking if is possible to create a new Bundle and "add" it to the code so that the game "merges" the resources from the AssetBundle called "level" with another one or more other AssetBundles (configurable).

    This is the code and i would love if someone could help me because i sadly can't help myself:


    Code (CSharp):
    1. public bool Loadbdl()
    2.     {
    3.         bool result;
    4.         try
    5.         {
    6.             if (MainMenu.Data != null)
    7.             {
    8.                 MainMenu.Data.Unload(false);
    9.             }
    10.             MainMenu.Data = AssetBundle.LoadFromFile("Venusian\\level");
    11.             MainMenu.MData = new MainData();
    12.             foreach (string text in MainMenu.Data.GetAllAssetNames())
    13.             {
    14.                 int num = 0;
    15.                 string text2 = text.Substring(text.LastIndexOf('/') + 1);
    16.                 text2 = text2.Substring(0, text2.IndexOf('.'));
    17.                 if (!text2.Contains("_icon_"))
    18.                 {
    19.                     if (text2.Contains("_"))
    20.                     {
    21.                         int.TryParse(text2.Substring(text2.LastIndexOf('_') + 1), out num);
    22.                     }
    23.                     else
    24.                     {
    25.                         int.TryParse(text2, out num);
    26.                     }
    27.                     if (num <= 500)
    28.                     {
    29.                         if (text2.StartsWith("wft_"))
    30.                         {
    31.                             MainMenu.MData.FaceW++;
    32.                         }
    33.                         else if (text2.StartsWith("mft_"))
    34.                         {
    35.                             MainMenu.MData.FaceM++;
    36.                         }
    37.                         else if (text2.StartsWith("wt_"))
    38.                         {
    39.                             MainMenu.MData.TattooW++;
    40.                         }
    41.                         else if (text2.StartsWith("mt_"))
    42.                         {
    43.                             MainMenu.MData.TattooM++;
    44.                         }
    45.                         else if (text2.StartsWith("wel_"))
    46.                         {
    47.                             MainMenu.MData.EyeLeaC++;
    48.                         }
    49.                         else if (text2.StartsWith("wm_"))
    50.                         {
    51.                             MainMenu.MData.MakeupC++;
    52.                         }
    53.                         else if (text2.StartsWith("mb_"))
    54.                         {
    55.                             MainMenu.MData.BeardC++;
    56.                         }
    57.                         else if (text2.StartsWith("me_"))
    58.                         {
    59.                             MainMenu.MData.BrowsMC++;
    60.                         }
    61.                         else if (text2.StartsWith("we_"))
    62.                         {
    63.                             MainMenu.MData.BrowsWC++;
    64.                         }
    65.                         else if (text2.StartsWith("wpu_"))
    66.                         {
    67.                             MainMenu.MData.PubesC++;
    68.                         }
    69.                         else if (text2.StartsWith("mpu_"))
    70.                         {
    71.                             MainMenu.MData.PubesMC++;
    72.                         }
    73.                         else if (text2.StartsWith("wn_"))
    74.                         {
    75.                             MainMenu.MData.NipplesC++;
    76.                         }
    77.                         else if (text2.StartsWith("cap_"))
    78.                         {
    79.                             MainMenu.MData.HeatC++;
    80.                         }
    81.                         else if (text2.StartsWith("wpa_"))
    82.                         {
    83.                             MainMenu.MData.PantieC++;
    84.                         }
    85.                         else
    86.                         {
    87.                             MainMenu.MData.PrintC++;
    88.                         }
    89.                     }
    90.                 }
    91.             }
    92.             result = true;
    93.         }
    94.         catch
    95.         {
    96.             GUIcontrol.blocks["reboot"].active = true;
    97.             this.UpdateError("          Data loading error          \n");
    98.             result = false;
    99.         }
    100.         return result;
    101. }
     
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    i don't think you can because asset bundle seats on top of a garbage pile called the unity asset loader which can only load one thing at a time, something to with locks
    hopefully this is not the case, i mean we're in 2021 right?
     
  3. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364