0

0 I'm loading 3d model from server url and using assetbundle but when i load the model in unityeditor it's working fine and the 3d model of cube is displaying proper. But when i load the model in android mobile the model is not displaying in the screen.

 IEnumerator GetAssetBundle() {

         string bundleURL = url;

         Debug.Log (bundleURL);
         using (WWW www = WWW .LoadFromCacheOrDownload(bundleURL, Version)) {
             yield return www;
             Debug.Log (Version);

             if (www .error != null)
                 throw new UnityException("WWW Download had an error: " + www .error);

             AssetBundle bundle = www .assetBundle;
             if (AssetName == "") {
                 Debug.Log ("null");
                 mBundleInstance = Instantiate (bundle.mainAsset) as GameObject;
                 mBundleInstance.transform.parent = imageTarget.transform;
                 mBundleInstance.transform.localPosition = new Vector3(0,0,0);


             }
             else {
                 Debug.Log ("not null");
                 mBundleInstance = Instantiate(bundle.Load (AssetName)) as GameObject;
             }
         }
     }
raj
  • 17
  • 9

1 Answers1

1

Asset bundles for ios, android and pc are not same thing. You should build those with respect to platform you are using.

Here is the script to make different asset bundles for different platforms.

Also you should know that you need Unity PRO to use asset bundles.

obywan
  • 854
  • 8
  • 14
  • I'm loading models from server url and i've used BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android); but it's not working – raj Jan 30 '15 at 17:44
  • I had the same problem with asset bundles for ios. To strike off possibility of not compatible versoin of file check your log for this error: `The file can not be loaded because it was created for another build target that is not compatible with this platform. Please make sure to build asset bundles using the build target platform that it is used by.` – obywan Feb 02 '15 at 13:41