Search Unity

Creating multiple Asset Bundles at the same time

Discussion in 'Asset Bundles' started by robrab2000-aa, Nov 20, 2019.

  1. robrab2000-aa

    robrab2000-aa

    Joined:
    Feb 8, 2019
    Posts:
    117
    Hi,

    We have about 70 or 80 prefabs that need to be loaded as asset bundles (with more being added regularly). So as to streamline the process I want to automate the process by setting up a watch folder that will convert prefabs dropped into it into asset bundles.

    I have it working at the moment but it is quite slow when doing all of them together:

    Code (CSharp):
    1. public static void MakeAssetBundle(string path, string bundleFolder, string bundleGuid)
    2.     {
    3.         // Add an asset to a bundle
    4.         AssetImporter assetImporter = AssetImporter.GetAtPath(path);
    5.         assetImporter.assetBundleName = bundleFolder + "/" + bundleGuid;
    6.         assetImporter.SaveAndReimport();
    7.     }
    My thinking is that its likely
    assetImporter.SaveAndReimport();
    that is slowing the process down as its probably refreshing the assetdatabase for each one. I was hoping I could add all the bundles and then just refresh the database manually, once at the end.

    Does anyone have any experience with this sort of thing?

    Thanks