String filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "AssetBundles") įilePath = System.IO.Path.Combine(filePath, assetBundleName)
#How do i run unity assets bundle extractor code
It is recommended to use Path.Combine to combine path names so the code below should use that instead.īelow is a simple loading function: IEnumerator LoadAsset(string assetBundleName, string objectNameToLoad) See comment in code for where these changes should be made. If using a prefab, pass GameObject instead then instantiate it. Since this is an image, Texture2D is passed to them. The AssetBundle and AssetBundleRequest API are used to load the AssetBundle.
To access all the folders use, Application.streamingAssetsPath + "/AssetBundle/" + assetbunlenameWithoutExtension. When loading it, Application.streamingAssetsPath should be used to access the StreamingAssets folder. You should see the built AssetBundles inside the Assets/StreamingAssets/AssetBundles directory. Build your AssetBudle by going to Assets -> Build AssetBundle menu. BuildPipeline.BuildAssetBundles(filePath, BuildAssetBundleOptions.None, BuildTarget.StandaloneOSX) ī. BuildPipeline.BuildAssetBundles(filePath, BuildAssetBundleOptions.None, BuildTarget.WebGL) BuildPipeline.BuildAssetBundles(filePath, BuildAssetBundleOptions.None, BuildTarget.Android) BuildPipeline.BuildAssetBundles(filePath, BuildAssetBundleOptions.None, BuildTarget.iOS) String filePath = Path.Combine(Application.streamingAssetsPath, folderName) īuildPipeline.BuildAssetBundles(filePath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64)
Create a script named ExportAssetBundles and put it in a folder named "Editor" in the Assets folder then copy the code below inside it: using System.IO For this example, name this folder AssetBundles so that you can use it to recognize what's in it.Ī. Create sub-folder in the StreamingAssets folder to hold the AssetBundle. Spelling counts and it's case sensitive so make sure to name it correctly.ģ. This is the folder we are going to build the AssetBundle into. Create a folder named StreamingAssets in the Assets folder. Click on the "None" option then go to the "New" option and create new AssetBundle and name it "animals"Ģ.
#How do i run unity assets bundle extractor how to
See the animated gif below for how to do this. Sometimes, the AssetBundle option it is hidden, drag it up to show it. In this case, that's the "dog.jpeg" file. In this example below, I will demonstrate how to add new asset called "dog" to our AssetBundle named "animals" and build it then load it during run-time.ġ. It might be related somehow to setting the correct path, but as I have copied the assetbundle folder afterwards to Xcode project, the problem persists. Users/user/Documents/Workspaces/unityproject/Assets/AssetBundles/iOS/lchairanimations I build the project to Xcode and run it in Xcode and receive this error: (Without the "file://" prefix, the bundles won't work in Unity nor Xcode) using them with AssetBundle bundleLoadRequest = AssetBundle.LoadFromFile("file://" + Application.dataPath + "/AssetBundles/iOS/" + myassetbundlename.ToString()) Īnd/or WWW + "/AssetBundles/iOS/" + myassetbundlename.ToString(), 4) In Unity I build the assetbundles: using UnityEditor īuildPipeline.BuildAssetBundles("Assets/AssetBundles", BuildAssetBundleOptions.None, BuildTarget.iOS) Īnd they work fine in Unity. I cannot get Unity Assetbundles working in an iOS build.