【问题标题】:AssetBundle loading model is not showing in mobileAssetBundle 加载模型未在移动设备中显示
【发布时间】:2015-01-30 10:10:33
【问题描述】:

0 我正在从服务器 url 加载 3d 模型并使用assetbundle 但是当我在 unityeditor 中加载模型时它工作正常并且立方体的 3d 模型显示正确。但是当我在 android mobile 中加载模型时,模型没有显示在屏幕上。

 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;
             }
         }
     }

【问题讨论】:

    标签: android unity3d gameobject assetbundle


    【解决方案1】:

    ios、android 和 pc 的资产包不是一回事。 您应该根据您正在使用的平台构建它们。

    Here is 为不同平台制作不同资产包的脚本。

    您还应该知道,您需要 Unity PRO 才能使用资产包。

    【讨论】:

    • 我正在从服务器 url 加载模型并且我使用了 BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android);但它不起作用
    • 我在 ios 的资产包中遇到了同样的问题。要消除文件版本不兼容的可能性,请检查您的日志中是否存在此错误: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.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多