x


About loading assetbundle in iphone

when i create a assetbundle and put it in the application.data path in iphone manually,then in the code ,i use the www to load the assetbunld, but it just return the error "load assetbundle fail" and the www.assetbundle is null.can anyone help ,thanks. i just use BuildPipeline to create the assetbundle.and the code is ok on windows and mac platform.

and i print the www.error msg ,it is "bad URL".but i can download the file from web browser. //the console message as below: //my assetbundle url to load by www

file:///Users/ios/Library/Application Support/iPhone Simulator/4.1/Applications/ABF0D1D0-F88B-41BC-883F-601BC0BC50D1/demo3.app/Data/../AssetBundles/CharacterElementDatabase.assetbundle

(Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/ExportGenerated/iPhoneSimulatorPlayerUnityLib/UnityEngineDebug.cpp Line: 34)

(Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/ExportGenerated/iPhoneSimulatorPlayerUnityLib/UnityEngineDebug.cpp Line: 34)

Failed to load asset bundle

(Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/Misc/AssetBundleUtility.cpp Line: 185)

bad URL

more ▼

asked Sep 05 '11 at 02:58 AM

wangqw1215 gravatar image

wangqw1215
16 7 7 8

I have the same problem:

public static string AssetBundleURL { get { if (Application.platform == RuntimePlatform.WindowsWebPlayer || Application.platform == RuntimePlatform.OSXWebPlayer) { return Application.dataPath + "/assetbundles/"; } else if(Application.platform == RuntimePlatform.IPhonePlayer) { return "file://" + Application.dataPath + "/Raw/assetbundles/"; } else { return "file://" + Application.dataPath + "/../assetbundles/"; } } }

I already checked if the files are in the path

file:///Users/dev/Library/Application Support/iPhone Simulator/5.0/Applications/E01747A0-F487-4415-825B-6095FDCBEE6E/rb.app/Data/Raw/assetbundles/ios.assetbundle

and they are...

But I get the following error:

bad URL

Feb 09 '12 at 06:13 PM Leonidax
(comments are locked)
10|3000 characters needed characters left

3 answers: sort newest

I found this really helpful, hopefully others looking here will too:

http://www.chrisdanielson.com/2011/05/03/unity3d-file-assetbundles-on-the-iphone/

It is possible to get access to files in the XCode project by first getting Asset.DataPath, and traversing the directory one level to files within the root of the xcode project, eg:

"file://" + Application.dataPath + "/../Packaged_iOS/" + bundleGroupNames[type] + ".unity3d";
more ▼

answered May 11 '12 at 04:05 PM

Fehr gravatar image

Fehr
76 2

(comments are locked)
10|3000 characters needed characters left

Hi, I've a similar problem. This local path seems fine to me. Usually with native iOS you load file with NSURL url = [NSURL urlWithString:@"file://..../Documents/filename"];

var urlFile = "file://" + GetiPhoneDocumentsPath() + "/savedassetbundle.assetbundle";
Debug.Log("---> loading file from: " + urlFile);

downloadFile = new WWW (urlFile);

yield downloadFile;

var assetBundleFile  = downloadFile.assetBundle;
if(assetBundleFile==null)
{
    Debug.Log("---> file not found");
    return;
}

On Unity this doesn't works... does anyone knows why?

more ▼

answered Jan 17 '12 at 06:52 PM

chiodo80 gravatar image

chiodo80
1 1 1 1

(comments are locked)
10|3000 characters needed characters left

It looks like the url you are trying to use is a local path on your computer:

file:///Users/ios/Library/Application Support/iPhone Simulator/4.1/Applications/ABF0D1D0-F88B-41BC-883F-601BC0BC50D1/demo3.app/Data/../AssetBundles/CharacterElementDatabase.assetbundle

This will of course not work on your iPhone.

more ▼

answered Sep 05 '11 at 12:07 PM

jonas echterhoff gravatar image

jonas echterhoff ♦♦
9.7k 7 23 102

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1999
x381

asked: Sep 05 '11 at 02:58 AM

Seen: 2634 times

Last Updated: May 11 '12 at 04:05 PM