纳金网

标题: 【脚本】 Unity3D AssetBundle 在Android机子上进行读取(转) [打印本页]

作者: lp5131427    时间: 2013-5-29 17:23
标题: 【脚本】 Unity3D AssetBundle 在Android机子上进行读取(转)
本帖最后由 艾西格亚 于 2013-5-30 01:32 编辑

用以下步骤进行在Android机子上使用AssetBundle
重点有2点:
Use the option "BuildTarget.Android".
Describe the path with triple slash "file:///"
以下是步骤:

Delete directories "Per Texture Materials", "assetbundles", and so on.  把已经导出过的包删掉
Use the option "BuildTarget.Android" to all "BuildPipeline.BuildAssetBundle".   要把BuildTarget为Android平台!!!
Run these on Editor. Character Generator/Generate Materials Character Generator/Create Assetbundles Character Generator/Update Character Element Database  
Copy Assetbundles database to Android device which like "/mnt/sdcard/assetbundles/"  把这些包放到Android的指定目录下
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/";
        }
    }
}

作者: libufan    时间: 2013-6-1 00:18
谢谢楼主分享
作者: werdsazxc    时间: 2013-6-2 23:08
感謝樓主教學~~
作者: 王者再临    时间: 2013-6-2 23:10
支持一个,很不错的内容!




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5