Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by ultramatrix · Mar 30, 2012 at 10:12 AM · androidbugassetbundleassetbundles

AssetBundles don't load to scene on Android device.

Open example projects as "CharacterCustomization" and "AssetBundles" and i tried all methods to load assetbundles into scene.

PURPOSE: loading files with resources - .unity3d (locally on Android the device)

Let's take for example the AssetBundles Tutorial project.

Scene: "Loader".

Compiled *.unity3d copied in the folder "./Assets/StreamingAssets/"

In the InstantiateResource.js file registered a way for version Android

 if (Application.platform == RuntimePlatform.Android)
 download = new WWW ("jar:file://" + Application.dataPath +"!/assets/" + url);

In the Unity editor works without mistakes. Build .apk version for Android. Run apk on the device (SGS 2). On GUI press the DOWNLOAD buttons. Then shows % ... 100% and UNLOAD. But in a scene anything isn't present!

I tried many ways. Tried to compile under Android4 started on the ICS device - too anything. Check files in APK of "assets" folder - .unity3d files presents.

Though the project works in PC/MAC/WebPlayer... And when project switched to Android - work. No works compiled APK on Android device (many devices used HTC, SonyErricsson).

Well. thought there can be a matter in JAVA. Opened the tutorial "CharacterCustomization" project. This project is written on C#. Also add code:

 ...
 if (Application.platform == RuntimePlatform.Android) 
 ...
 ...  "jar:file://" + Application.dataPath +"!/assets/" ...

Just the same problems. Everywhere works except Android devices! On scene nothing, not create.

Maybe this is BUG on engine(Android)? Or how to build loading of assetbundles on android device?

ZIP of AssetBundle example: http://www.sendspace.com/file/uizyxh

Unity 3.5 Android 2.3.6 and 4 (both on Samsung Galaxy S II)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ultramatrix · Mar 30, 2012 at 09:48 AM 0
Share

please answer somebody!

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by pesche · Apr 16, 2012 at 03:49 PM

I have exactly the same problem with Android and Asset Bundles. Therefore I hope anybody could give us some hints.

thanks

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image elixir-bash · Nov 09, 2012 at 06:20 AM 0
Share

Hey pesche , di you get a solution fo rthis. Im trying to load asset bundle from sd card. I use www.LoadFromCacheOrdownload(path,version). The file exists , but when i check for bundle it says null:(

avatar image
0

Answer by udaanparvaz · Jul 25, 2012 at 12:33 PM

This may be late to answer but i think the script that you are using to build .unity3d assetBundles is missing the BuildTarget.Android in BuildPipeline.BuildAssetBundle arguments

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image elixir-bash · Nov 09, 2012 at 06:21 AM 0
Share

Hey udaan, di you get a solution fo rthis. Im trying to load asset bundle from sd card. I use www.LoadFromCacheOrdownload(path,version). The file exists , but when i check for bundle it says null. I actually do set the optional parametrer when i took a build for asset bundle

avatar image udaanparvaz · Nov 10, 2012 at 08:05 AM 0
Share

I've done this without any problems or whatsoever...use a script to make asset bundle and make sure the script contains BuildTarget.Android....and then load the assetBundle using WWW class...I would suggest to Use Application.Persistentdatapath for android....which usually points to mnt/sdcard/Android/data/your_package_name/files/ dir on Android

avatar image elixir-bash · Nov 14, 2012 at 07:47 AM 0
Share

this is exactly what i have done, but i get a argument null reference when i access the bundle from another script.

avatar image
0

Answer by shaystibelman · Nov 14, 2012 at 10:30 AM

Here are my scripts for saving an asset bundle from an entire scene and then loading it into another scene:

Save asset bundle:

 import System.IO;
 #pragma strict
 #pragma downcast
 
 @MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")
 static function ExportResource () {
     // Bring up save panel
     var path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d");
     if (path.Length != 0)
     {
         // Build the resource file from the active selection.
         var selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
         
         BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets);    
         /*
         BuildPipeline.BuildPlayer
         BuildOptions.BuildAdditionalStreamedScenes
         */
         
         Selection.objects = selection;
     }
 }
 
 @MenuItem("Assets/Build AssetBundle From Selection - No dependency tracking")
 static function ExportResourceNoTrack () {
     // Bring up save panel
     var 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);
     }
 }
 
 @MenuItem ("Build/ExportToWebplayer")
 static function MyBuild4web(){
     var lvlname : String = Application.dataPath+"/"+Path.GetFileName(EditorApplication.currentScene);
     var level : String[] = [lvlname];
     BuildPipeline.BuildStreamedSceneAssetBundle(level, "Assets/StreamingAssets/"+Path.GetFileNameWithoutExtension(EditorApplication.currentScene)+"pkg.unity3d", BuildTarget.WebPlayerStreamed); 
 }
 @MenuItem ("Build/ExportToAndroid")
 static function MyBuild4android(){
     var lvlname : String = Application.dataPath+"/"+Path.GetFileName(EditorApplication.currentScene);
     var level : String[] = [lvlname];
     BuildPipeline.BuildStreamedSceneAssetBundle(level, "Assets/StreamingAssets/Android/"+Path.GetFileNameWithoutExtension(EditorApplication.currentScene)+"pkg.unity3d", BuildTarget.Android); 
 }


(This code is to be put in an EDITOR folder directly in your ASSETS folder!)

The code to import the asset bundle:

 if (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer){
         download = new WWW.LoadFromCacheOrDownload ("../StreamingAssets/" + url,1);
     }
     yield download;
     if (download.error != null)
     {
         Debug.Log(download.error);
         return;
     }else{
         var asset : AssetBundle = download.assetBundle;
         var async : AsyncOperation = Application.LoadLevelAdditiveAsync(StoreName);
        }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can a windows and an android app use the same assetbundle specified with no target?,Can Windows and Android apps run assetsbundles with notarget? 0 Answers

AssetBundleManager.LoadAssetAsync() doesn't work on some android devices (or is very slow) 2 Answers

Using AssetBundles throughout project 0 Answers

black screen after the first play on android 0 Answers

Asset Bundle with script ? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges