Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Broadcasting AssetBundle on SpriteAtlas

Discussion in 'Asset Bundles' started by LightStriker, Sep 9, 2019.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,594
    As described in the documentation https://unity3d.com/fr/learn/tutorials/topics/best-practices/assetbundle-usage-patterns

    So... Let's say you have a SpriteAtlas referencing thousands of icons in dozen of different folders.
    Have fun flagging them all with the same AssetBundle, right?

    Free tool to do that, select your SpriteAtlas and run it;

    Code (CSharp):
    1.         [MenuItem("Tools/Asset Bundles/Broadcast AssetBundle")]
    2.         static void BroadcastAssetBundle()
    3.         {
    4.             AssetImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(Selection.activeObject));
    5.             string bundle = importer.assetBundleName;
    6.  
    7.             foreach (string path in AssetDatabase.GetDependencies(AssetDatabase.GetAssetPath(Selection.activeObject)))
    8.             {
    9.                 importer = AssetImporter.GetAtPath(path);
    10.                 importer.assetBundleName = bundle;
    11.             }
    12.         }
     
unityunity