在Android机子上进行AssetBundle 读取

本文详细介绍了如何在Android设备上正确使用AssetBundle,并提供了关键步骤和代码示例,确保了资源的跨平台兼容性。通过设置特定的BuildTarget和修改AssetbundleBaseURL,可以实现在Android设备上的顺利加载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

原址:http://blog.youkuaiyun.com/chiuan/article/details/7387502

 

我看到官方文档中说明:
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.

但是我们看到,用以下步骤进行在Android机子上使用AssetBundle

重点有2点:

  1. Use the option "BuildTarget.Android".
  2. Describe the path with triple slash "file:///"

以下是步骤:

  1. Delete directories "Per Texture Materials", "assetbundles", and so on.  把已经导出过的包删掉
  2. Use the option "BuildTarget.Android" to all "BuildPipeline.BuildAssetBundle".   要把BuildTarget为Android平台!!!
  3. Run these on Editor. Character Generator/Generate Materials Character Generator/Create Assetbundles Character Generator/Update Character Element Database  
  4. Copy Assetbundles database to Android device which like "/mnt/sdcard/assetbundles/"  把这些包放到Android的指定目录下
  5. Modify AssetbundleBaseURL. (the point was "file:///") 修改获取AssetbundleBaseURL基础路径的地址

 

public static string AssetbundleBaseURL
{
    get
    {
        if (Application.platform == RuntimePlatform.WindowsWebPlayer || Application.platform == RuntimePlatform.OSXWebPlayer)
        {
            return Application.dataPath + "/assetbundles/";
        }
        else if (Application.platform == RuntimePlatform.Android)
        {
            return "file:///mnt/sdcard/assetbundles/";
        }
        else
        {
            return "file://" + Application.dataPath + "/../assetbundles/";
        }
    }
}



 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值