Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ZeFirestarter · Nov 06, 2015 at 11:24 AM · androidassetbundleurlurl schemes

Android wont load AssetBundle scene - using AssetBundleManager from the tutorial (Unity 5.2.1)

Hello dear Unity Community.

I'm fairly new to Unity and I'm trying to learn how to use AssetBundles in Unity as I will need them for the next app. I found this AssetBundle tutorial and decided to use the AssetBundleManager included in the downloadable sample project. In the 'Build Settings' I switched to Android Platform. I build the AssetBundles (for Android platform). I want to load a scene from the AssetBundle. When I'm in the editor I used three different ways to load the AssetBundle scene. First I tried it in 'Simulation Mode ', then the 'Local AssetBundle Server' and finally I uploaded the AssetBundle to a server and accessed it through the url. Everything worked perfectly in the editor.

When I try it on my Android devices it won't download from the URL.

I use the scene and AssetBundle given in the tutorial project. The AssetBundle is named 'scene-bundle'. Let's say I upload it to this site: http://www.MyWebsite.com/AssetBundles/ then the AssetBundle file url would be this: http://www.MyWebsite.com/AssetBundles/Android/scene-bundle

In the editor it worked when I gave this url: http://www.MyWebsite.com/AssetBundles/ because the script detects which platform I'm in and the name of the AssetBundle is given in a string beforehand.

the Script-line reads like this:

 AssetBundleManager.SetSourceAssetBundleURL("http://www.MyWebsite/MyAssetBundles");

In the comment above it says this:

Customize the URL based on your deployment or configuration

So my guess is, that I just can't write the url like that and need to adapt it to Android?

The error I get is the following:

Failed downloading bundle scene-bundle from http://www.MyWebsite.com/AssetBundles/Android/scene-bundle: Invalid Unity Web File (Decompression Failure). URL: http://www.MyWebsite.com/AssetBundles/Android/scene-bundle

I tried to use WWW because I thought that might help, but I failed miserably.

All the answers I found were a couple of years old and nobody is using the unity AssetBundleManager. The tutorial is also fairly recent, Date: 11 Sep 2015.

Any help would be greatly appreciated. I'm sorry for being such a noob, thank you for your time.

Comment
Add comment · Show 7
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 digzou · Nov 13, 2015 at 11:36 AM 0
Share

Did you create separate bundles for your editor as well as for android? From what I see, I think you are trying to use the same bundle("scene-bundle") for every platform.

avatar image ZeFirestarter digzou · Nov 13, 2015 at 12:47 PM 0
Share

Thank you for your time, but as I stated above I build the AssetBundles for Android platform. They also work in the editor if Android is selected as platform in the Build Settings.

$$anonymous$$y problem is I don't know how to load assets or scenes using the AssetBundle$$anonymous$$anager. I just managed to load assets without the $$anonymous$$anager using the code posted here. That works on my Android devices. Scenes have proven to be more difficult, I haven't accomplished it yet.

avatar image digzou ZeFirestarter · Nov 13, 2015 at 01:23 PM 0
Share
     IEnumerator DownloadBundleAndCache (string BundleURL){
         // Wait for the Caching system to be ready
         while (!Caching.ready)
             yield return null;
         
         // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
         using(www = WWW.LoadFromCacheOrDownload (BundleURL, version)){
 
             //DOWNLOADING...
 
             yield return www;
 
             //DOWNLOADING CO$$anonymous$$PLETE
 
             if (www.error != null){
 
             Debug.LogError("WWW download had an error:" + www.error);
                 
             }
             else{
                 
                 _instance.bundle = www.assetBundle;
                 
                 if (AssetName == "")
                     Instantiate(bundle.mainAsset);
                 else{
                     string path = "assets/resources/images/myImage.png"; //How I load my Sprite. Load other resources similarly.
                     Sprite sprite = bundle.LoadAsset<Sprite>(path);
                 }
 
                 bundle.Unload(false);
                 
             }
     }
 }


Something what I use. See if it helps.

Show more comments
Show more comments
avatar image memetic-arts · Dec 27, 2015 at 03:30 PM 0
Share

@Digzou, can you provide a link, please, to the doc where it says that LoadLevelAsync is Pro-only? I would think that if Unity 5 has enabled AssetBundle functionality in the personal edition, then the features/functions included in the tutorial would be valid for all versions. If not, well, that'd be a little messed up.

@ZeFirestarter , I saw your post in the tutorial thread as well, and as I said over there, I've been having a similar issue . . . did you ever get this resolved?

Thanks in advance to you both!

avatar image memetic-arts memetic-arts · Dec 28, 2015 at 03:08 AM 0
Share

@ZeFirestarter, that's what I was asking you! I thought maybe since your issue was older that you may have figured it out by now. I just posted in the tutorial thread yesterday. :-)

In any case, @twobob has pointed out that this (my issue, at least, maybe yours as well) is due to a $$anonymous$$I$$anonymous$$E type / server config problem, which I'm in the middle of resolving . . . will post progress in the tutorial thread.

cheers

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ZeFirestarter · Feb 01, 2016 at 12:35 PM

So now I'm working with Unity 5.3.1 with the same Tutorial/AssetPackage and it worked on the first try on Android. It loads the asset example, the scene and the variants examples. All work on Android and none of them work on iOS :-/. I made the AssetBundle with iOS selected as platform (while using Windows) and uploaded that AssetBundle. I'll try again later creating and uploading the assBundle from the Mac.

What also gave me problems was a compression error, that was because I was uploading the AssetBundles with Filezilla. Go to "Options -> Transfer -> Data Type -> un-check the first box with the ASCII-data (you can leave the one with 'dotfiles' checked) (I have the German version that's why I don't know exactly what it says in English).

If anyone has questions how to get the AssetBundleManager to work on Android, let me know. Write here or PM me, I'll be sure to help as much as I can. Cheers.

Comment
Add comment · Show 4 · 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 dearnightmare · Feb 05, 2016 at 06:22 AM 0
Share

Dude, this is exactly the problem I was having, cheers!

avatar image Gianluca90 · Oct 03, 2016 at 08:29 AM 0
Share

Hello @ZeFirestarter! Could you help me to build an Asset Bundle for Android?

avatar image itzjac_dagon Gianluca90 · Dec 09, 2016 at 05:32 PM 0
Share

@ZeFirestarter

Do you think there will be too many differences for a pc build? should be simpler, right? Can I pm you if this is the case

avatar image vickysuresh · Jun 07, 2017 at 12:17 PM 0
Share

hi @ZeFirestarter i am facing same issue in andriod ,while running application in editor its works fine where it does not work in andriod device ,how to overcome this using asset bundle manager please let me know as soon as possible

Thank you in advance, vignesh

avatar image
0

Answer by RanjithSoman · Apr 02, 2017 at 09:55 AM

I am using unity3d 5.5.2f1 and vuforia 6.2 sdk. I have built asset bundles for android and uploaded it to my [server][1]. I am using vuforia to detect markers and then attach the asset bundle to the marker. The script works well in the editor. However after building it and running on the android, it doesn't work. I checked whether its problem with vuforia by attaching another game object to the target. That one appears while on editor and on phone. However only gameobject is getting attached after building on to android and not the assetbundle.

  using System;
  using UnityEngine;
  using System.Collections; 
  using Vuforia;
  public class Loadmyasset : MonoBehaviour, ITrackableEventHandler 
  {
      public string AssetName;
      public int Version;
      private GameObject mBundleInstance = null;
      private TrackableBehaviour mTrackableBehaviour;
      private bool mAttached = false;
      public string BundleURL;
  
      void Start()
      {
          StartCoroutine(DownloadAndCache());
          mTrackableBehaviour = GetComponent<TrackableBehaviour>();
          if (mTrackableBehaviour)
          {
              mTrackableBehaviour.RegisterTrackableEventHandler(this);
          }
      }
      IEnumerator DownloadAndCache ()
      {
  
          // Wait for the Caching system to be ready
          while (!Caching.ready)
              yield return null;
          BundleURL = "http://rksunityftpserver.x10host.com/assetbundle/Android/tree.unity3d";
          // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
          using (WWW www = WWW.LoadFromCacheOrDownload (BundleURL, 1))
          {
              yield return www;
              if (www.error != null)
                  throw new Exception("WWW download had an error:" + www.error);
              AssetBundle bundle = www.assetBundle;
              if (AssetName == "")
                  Instantiate(bundle.mainAsset);
              else
                  Instantiate(bundle.LoadAsset(AssetName));
              // Unload the AssetBundles compressed contents to conserve memory
              bundle.Unload(false);
  
          } // memory is freed from the web stream (www.Dispose() gets called implicitly)
      }
  
      public void OnTrackableStateChanged (TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
      {
          if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) 
          {
              
              if (!mAttached && mBundleInstance) {
                  // if bundle has been loaded, let's attach it to this trackable
                  mBundleInstance.transform.parent = this.transform;
                  mBundleInstance.transform.localScale = new Vector3 (10.0f, 10.0f, 10.0f);
                  mBundleInstance.transform.localPosition = new Vector3 (0.0f, 0.15f, 0.0f);
                  mBundleInstance.transform.gameObject.SetActive (true);
                  mAttached = true;
              }
          
          }
      }
  }

Please help me on this issue [1]: http://rksunityftpserver.x10host.com/assetbundle/Android/

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

43 People are following this question.

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

Related Questions

Streaming scenes in assetbundles 1 Answer

Asset Bundles with In-App Payment in Unity Mobile 1 Answer

How to get Updated Context in Unity3D Android when app is open from Backgroung? 1 Answer

Downloading Asset Bundle on Android and Saving to File 1 Answer

I I'm trying to make a Build Android App Bundle with asset bundle but it gives me the following error, i try to integrate asset delyveri 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