Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Asset Bundle problem...

Discussion in 'Editor & General Support' started by Stanley-Joy, Jul 23, 2014.

  1. Stanley-Joy

    Stanley-Joy

    Joined:
    Feb 12, 2013
    Posts:
    12
    I have been trying to use AssetBundle for some time. To my misfortune I can't get it to work on the device.
    I have created 2 bundles one for WP8 and the other for PC, the bundle contains just 3D models and NO scripts whatsoever.
    The PC one works well in the editor whereas the WP8 bundle loads but does not Instantiate on device.
    I have checked the logs for any sort of error or null reference but could not find anything.

    Here is my code to download and instantiate the assetbundle.
    Code (CSharp):
    1. void Start (){
    2. StartCoroutine(load(loadUrl, 2));
    3. }
    4.  
    5. private IEnumerator load(string url, int version) {
    6.         // wait for the caching system to be ready
    7.             using (WWW www = new WWW(url)) {
    8.             wwwT = www; //This definition is used to get the progress which is accessed in the OnGUI
    9.             yield return www;
    10.             if (www.error != null)
    11.                 throw new Exception("WWW download had an error:" + www.error);
    12.             AssetBundle bundle = www.assetBundle;
    13.             Instantiate(bundle.mainAsset);
    14.             Debug.Log("INSTANTIATE!");
    15.             flag = false;
    16.             // Unload the AssetBundles compressed contents to conserve memory
    17.             //bundle.Unload(false);
    18.          
    19.         }
    Thanks in Advance,
    Stanley J. Maliackal
     
    Last edited: Jul 23, 2014
  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,967
    Where are your bundles stored? Are they somewhere your device can see them?
     
  3. Stanley-Joy

    Stanley-Joy

    Joined:
    Feb 12, 2013
    Posts:
    12
    @zombiegorilla
    The bundles are stored in a server and is retrieved using the above method. After retrieval the bundles are stored in the RAM as I am not saving them to a separate file location or using WWW.LoadFromCacheOrDownload.

    Stanley J. Maliackal
     
  4. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,967
    Gotcha. I was asking because I typically store them in the local file system during dev, point the WWW to "file://". I have on occasion forgot to switch that when I build to device. Have you tried it on other devices?
     
  5. Stanley-Joy

    Stanley-Joy

    Joined:
    Feb 12, 2013
    Posts:
    12
    Just WP8 and PC. Have not tried on iOS and Android.

    Stanley J. Maliackal
     
  6. Stanley-Joy

    Stanley-Joy

    Joined:
    Feb 12, 2013
    Posts:
    12
  7. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    I guess that will be the same case with WP8 ?