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
0
Question by Leaf1 · Jan 16, 2016 at 04:27 PM · androiderrorassetbundle

Android Assets Bundle Error

hi there, i'm using Unity 5 Pro and i'm trying to manage assets bundle on Android platform, all work perfectly on editor but on android i get NullReferenceException, i dont know how to solve it :(

that's the code to build asset:

 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, BuildTarget.Android);
             Selection.objects = selection;
         }
     }
 }

and tha'ts the code to load and instantiate asset:

 using UnityEngine;
 using System.Collections;
  
 public class AssetLoader : MonoBehaviour {
  
     public static AssetLoader Instance;
  
     private string url = "http://download1639.mediafire.com/rbw69d868j0g/s1vkw7gaju3yk0s/BannerBundle.unity3d";
     public int version = 1;
  
     AssetBundle bundle;
     IEnumerator Start () {
         WWW www = WWW.LoadFromCacheOrDownload (url, 1);
  
         yield return www;
         AssetBundle bundle = www.assetBundle;
         Debug.Log(bundle.name);
         yield return bundle;
         GameObject obj = Instantiate(bundle.LoadAsset("myObject"), Vector3.zero, Quaternion.identity) as GameObject;
         Debug.Log(obj);
     }
 }

Thanks for help

Comment
Add comment · Show 2
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 hexagonius · Jan 16, 2016 at 04:40 PM 0
Share

Please post the error so one can see which line

avatar image Leaf1 hexagonius · Jan 16, 2016 at 05:22 PM 0
Share

I am close to the solution, if I try to download the package with wifi working properly, with 3g it me back a bundle null, I tried to do a loop that redownload the bundle until it returns true, but enters into an infinite loop (I tried to control the www.progress and up to 100 each time) that's the new code:

     void Awake () {
         DontDestroyOnLoad(this.gameObject);
         StartCoroutine(Download());
     }
  
     IEnumerator Download () {
         www = new WWW (url);
         yield return www;
         yield return new WaitForSeconds(1);
         if(www.isDone) {
             if (www.assetBundle == null)
                 StartCoroutine(Download());
             else if (www.assetBundle != null)
                 Instantiate();
         }
     }

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Android Build Error 2 Answers

Help with SQLite for Android Errors in Unity3D? 1 Answer

Sound file Asset bundle not decompress 0 Answers

APK Can't be open in Android system microphone 0 Answers

CommandInvokationFailure: Failed to re-package resources 1 Answer


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