

Unload Asset Bundle from memory (but do not destroy the existing instance(s)) Instantiate(playerPrefab, Vector3.zero, Quaternion.identity) GameObject playerPrefab = assetBundle.LoadAsset("FPSPlayer") as GameObject Extract Prefab named "FPSPlayer" from the Asset Bundle Using ( (uint)assetBundleVersion, 0))ĭebug.LogError("AssetBundle Error: " + String assetBundlePath = "file://" + Application.dataPath + "/_Bundles/" + "fpsplayer" // Path to Asset Bundle file
Unity assets bundle extractor can you export multiple files code#
The code below downloads Asset Bundle named "fpsplayer" then extracts the Prefab named "FPSPlayer" and instantiates it in the Scene: int assetBundleVersion = 1 // Changing this number will force Asset Bundle reload Generally, there are 2 types of Asset Bundles, those that contain assets and those that contain Scenes. To load the Asset Bundle it first needs to be downloaded using UnityWebRequest then unpacked using a special function. Clicking it will build the Asset Bundles and place them in "_Bundles" folder. If (!AssetDatabase.IsValidFolder(outputFolder))ĭebug.Log("Folder '_Bundles' does not exist, creating new folder") ĪssetDatabase.CreateFolder("Assets", "_Bundles") īuildPipeline.BuildAssetBundles(outputFolder, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget) Īfter saving it you'll notice it will add a menu button (Build -> Build AssetBundles).

Use Asset Bundles when your game has a lot of assets and you do not want to include them in the main build. Scripts however cannot be included in Asset Bundles, only their references, so be careful when renaming or moving them, as it will break the connection and you'll need to rebuild the Asset Bundles to make them work again. What Are Asset Bundles?Īsset Bundles are files that contain game assets, from simple assets such as 3D models, textures, audio clips, and more complex, such as Scenes and Prefabs, that can be later loaded into the game.

Unity has many useful features, one of them is support for Asset Bundles.
