• 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
0
Question by xproject2013 · Mar 27, 2014 at 04:57 PM · c#androidassetbundleloadassetatpath

Android texture AssetBundles loading problem

hi everyone, I'm trying to load images from an assetbundles but when I load the texture in the scene the image appear broken, I post the link at the file that I used to see if the problem is caused from some picture settings:

http://dev.x-project.it/bundles/AssetsTest.zip

In the file in the resources folder you can find the original image that i use for create the bundles. I'd like to know if the script that I use for export the bundles for the different device is correct, i post it below.

I cant load the bundle in the editor mode and i don't understand where is the mistake, you can find the script in the "app" gameobject, maybe is only a wrong path setting but i've tried all the possibilities and it doesn't works.

Another big problem is when i execute the "build and run" on Android device (Galaxy Tab 2) the application crashes immediately. in most cases the application when start, immediately minimize in the task bar so i have to reopen it again, sometimes more than one time before it works.

On WebPlayer everything works fine.

Any suggestion? Thanks in advance

 using UnityEngine;
 using System.Collections;
 
 public class ExampleLoadingBundle : MonoBehaviour {
 
     public GUIText label;
     public GUIText urlLabel;
     public GUITexture pic;
 
     public string url; // URL AssetBundle
     public int version = 1; // AssetBundle version
     
     public string assetName; // Name of the Asset to be loaded from the AssetBundle
     public string assetPath; // Path to the Asset in the Project folder
     
     Object ObjInstance; // Instance of the object
 
     string deviceFolder;
 
 
     GameObject obj;
     Texture2D texture;
 
     GameObject objects;
 
 
     void Awake(){
         #if UNITY_WEBPLAYER
         deviceFolder = "webplayer";
         #endif
         #if UNITY_ANDROID
         deviceFolder = "android";
         #endif
         
         url = "http://dev.x-project.it/bundles/" + deviceFolder + "/compositions2.unity3d";
         urlLabel.text = url;
         assetPath = "Assets/Resources/" + deviceFolder + "/compositions.unity3d"; 
     }
 
 
     void Start(){
         StartCoroutine(Download());
     }
 
 
     IEnumerator Download () {
         AssetBundleLoader assetBundleLoader = new AssetBundleLoader ();
         yield return StartCoroutine(assetBundleLoader.LoadBundle <Texture2D> (url, version, assetName, assetPath));
         if (assetBundleLoader.Obj != null) {
 
             texture = Instantiate (assetBundleLoader.Obj) as Texture2D;
             pic.texture = texture;
             //pic.pixelInset.x
             label.text = pic.name + " -- " + pic.pixelInset;
 
             Debug.Log (label.text);
         } else {
             label.text = " Load failed!";
 
             Debug.Log (label.text);
         }
     }
 
 
 }
Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

20 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

Related Questions

Multiple Cars not working 1 Answer

Including scripts in AssetBundles on iOS 1 Answer

In an Addressable system, how to manage multiple profiles with different Remote Load Path without making a new build? 0 Answers

AssetBundle Android 1 Answer

AssetBundles are not working outside editor on PC or Android. 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges