- Home /
assets bundle for ios
Hi guys
I want to make assets bundle for ios .i have done for web player but when i download that bundle for ios it show me error
Please make sure to build asset bundles using the build target platform that it is used by. File's Build target is: 6 (Filename: Line: 625) Failed to read file 'none' because it is corrupted. (Filename: Line: 444) The asset bundle ' https://dl.dropboxusercontent.com/u/76813056/Bundles/Bundle.unity3d' can't be loaded because it was not built with the right version or build target. here is my code for making assets bundle using UnityEngine; using UnityEditor; public class ExportAssetBundles { [MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")] static void ExportResource () { // Bring up save panel string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // Build the resource file from the active selection. Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets); Selection.objects = selection; } } [MenuItem("Assets/Build AssetBundle From Selection - No dependency tracking")] static void ExportResourceNoTrack () { // Bring up save panel string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // Build the resource file from the active selection. BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path); } } } and for getting assets code ishe file can not be loaded because it was created for another build target that is not compatible with this platform.
IEnumerator Start() { //float timebefore; //float timeafter; //StartCoroutine("CheckInternetWorking"); // Download the file from the URL. It will not be saved in the Cache using (www = new WWW(BundleURL)) { yield return www; if (www.error != null) { Debug.Log("error = "+www.error); } AssetBundle bundle = www.assetBundle; Instantiate(bundle.mainAsset); bundle.Unload(false); } } please help me i am in trouble ,i want to make a assets bundle for ios and load on device and sorry for my english Thanks in advance
Answer by foobuggy · Dec 09, 2013 at 07:16 PM
This post already has a valid answer, but on a side not you could also use:
EditorUserBuildSettings.activeBuildTarget instead of BuildTarget.iPhone
That way, your bundles should be built correctly for whichever platform you currently have chosen as the build target.
Answer by Graham-Dunnett · Jul 04, 2013 at 02:21 PM
Switch build platform to iOS, then run your AssetBundle creation code again.
when i switch my platform web to ios and made assets bundle it automatically change my project to web,i switch ios but after making assets bundle its change automatically in web and that assets bundle shows me same error.
Answer by madhur · Nov 09, 2013 at 06:46 PM
I had a similar issue and fixed it by changing a line in the ExportAssetBundles script. There in line BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.iPhone); Added BuildTarget.iPhone to the end.
Now it works.
Answer by tatterson · Mar 15, 2016 at 08:50 PM
I was building the Asset Bundles for Android like so and it did not work:
BuildPipeline.BuildAssetBundles("Assets/AssetBundles", BuildAssetBundleOptions.None, BuildTarget.Android);
But when I changed to this, it worked:
BuildPipeline.BuildAssetBundles("Assets/AssetBundles", BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
What a headache!
Your answer
Follow this Question
Related Questions
How do you set asset bundle name on prefab through code? 0 Answers
Sharing user-generated content (with AssetBundle) 0 Answers
Addessable asset download once 0 Answers
How do you package/retrieve Asset Bundle Dependencies 0 Answers
Asset Bundle with script ? 0 Answers