AssetBundle

本文探讨了在Unity中使用代码加载AssetBundle遇到的问题及解决思路。作者使用Unity 4.1.5f1版本尝试加载AssetBundle时遇到了兼容性问题,并通过更换Unity版本到4.2.2f1解决了部分问题。文章还提到了跨平台兼容性和AssetBundle的使用限制。
在unity中使用代码,理论上来说可以加载assetbundle。
 
using UnityEngine;
using System.Collections;

public class AssetBundleLoader : MonoBehaviour {

     // Use this for initialization
     void Start () {
          StartCoroutine( LoadAssetBundle("file:///D:\\Projects\\cq_rip\\DataAndroid\\character\\br_000_b.ab") );
     }
    
     // Update is called once per frame
     void Update () {
    
     }
    
     IEnumerator LoadAssetBundle(string url) {
          WWW www = new WWW(url);
          yield return www;
    
          GameObject obj = (GameObject)Instantiate(www.assetBundle.mainAsset);
          yield return obj;
     }
}
 
备注:在windows上需以file:///开头。
 
得到的错误信息是:
 
 
可以预想应该是unity版本不同,打开assetbundle,可以看到
 
 
意思是兼容版本是3.x.x ~ 4.2.2f1吗?
 
我使用的unity版本是4.1.5f1。开发团队使用的版本应该是4.2.2f1,它可以向下兼容某个范围的assetbundle?
 
此报道网页也证实了unity版本至少是4.2。
 
下载中。。。unity也越来越大了啊。。
换个地方下载,用迅雷,快些。
 
用unity 4.2可以正常deserialize assetbundle,但是却加载不出任何asset。可能的问题,为安卓做的assetbundle不能够在PC上加载。
AssetBundleNamespace: UnityEngine
Parent class:  Object
Description

AssetBundles let you stream additional assets via the WWW class and instantiate them at runtime. AssetBundles are created via BuildPipeline.BuildAssetBundle.

Note that bundles are not fully compatible between platforms. A bundle built for any of the standalone platforms (including webplayer) can be loaded on any of those platforms but not on iOS or Android. Furthermore, a bundle built for iOS is not compatible with Android and vice versa.
 
思路其实现在应该是这样的了,做一个简单的安卓项目,然后在安卓设备上解压缩。
 
不过现在看来意义不是很大了,因为似乎没有办法做到在unity工程里面直接打开。
我现在想看的就是那个初始场景的第一个模型,到底有没有子模型,各自用的是什么材质。
 
 
 
不工作。可能还是有一些防护,或许是在serialize的时候可以有一些定制?

转载于:https://www.cnblogs.com/123ing/p/3944789.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值