下载OBB插件包

http://pan.baidu.com/s/1c0ouRZE

1、导入插件

注意事项:

如果项目中已经存在Android 插件,需要merge导入的xml文件例如 AndroidManifest.xml和strings.xml文件,否则编译或运行的时候可能会报错.

2、修改GooglePlayDownloader.cs 文件中的key改成你的key.

3、勾选 Player Settings ->Publishing Settings中的split Application Binary.

4、编译发布

以下是结合Ngui进度条代码示例:

using UnityEngine;
using System.Collections; public class DownLoadObb : MonoBehaviour { private string expPath;
private string logtxt;
private bool alreadyLogged = false; private bool downloadStarted = false;
private string uri;
// private string mainPath; public GameObject downloadButton; public UILabel progress; public UISlider progressBar; void Awake(){ }
void Start(){
if (!GooglePlayDownloader.RunningOnAndroid())
{ return;
} expPath = GooglePlayDownloader.GetExpansionFilePath();
if (expPath == null)
{ return ;
}
else
{
string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
// string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath);
if (mainPath == null ){
downloadButton.SetActive(true); }
StartCoroutine(loadLevel());
}
} public void DownLoad(){
GooglePlayDownloader.FetchOBB();
} void Update (){
if(!www.isDone){
progress.text = "Loading data file... "+(www.progress*).ToString("f2")+"%";
progressBar.sliderValue = www.progress;
}
} WWW www;
IEnumerator loadLevel(){
string mainPath;
do{
yield return new WaitForSeconds(0.5f);
mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
}
while(mainPath == null); progress.gameObject.SetActive(true);
progressBar.gameObject.SetActive(true);
downloadButton.SetActive(false); if(downloadStarted == false){
downloadStarted = true; uri = "file://" + mainPath; www = WWW.LoadFromCacheOrDownload(uri,); yield return www; if(www.error == null){
Application.LoadLevel("Menu");
}
}
}
}

最新文章

  1. C#设计模式系列:工厂方法模式(Factory Method)
  2. Codeforces Round #280 (Div. 2)E Vanya and Field(简单题)
  3. (转)探讨:ASP.NET技术的学习顺序问题
  4. nefu 519 昨日重现
  5. MUI 页面传值,因为用的是H5+ plus方法所以要在真机上才能测试出效果
  6. (84)Wangdao.com第十八天_JavaScript Promise 对象
  7. Windows系统配置
  8. linux 硬盘
  9. Ubuntu下将python从2.7升级到3.5
  10. nginx+php负载均衡集群环境中的session共享方案梳理
  11. 前端学习历程--js--原型&闭包
  12. tomcat jetty
  13. Html_兼容性
  14. 转 linux下php扩展mysqli的支持
  15. greendao数据库初次使用的配置及多表关联的初始化
  16. 1012 The Best Rank (25 分)
  17. catch异常
  18. 80端口占用异常解决方法java.net.BindException: Address already in use: JVM_Bind:80(或8080)
  19. News summary on C# and .NET
  20. C语言编程练习 GPS数据处理

热门文章

  1. NET Memory Profiler 跟踪.net 应用内存
  2. Minimum Window Substring
  3. C++构造函数与析构函数
  4. php基础03:数据类型
  5. LeetCode-Count Univalue Subtrees
  6. Week2学习过程报告
  7. 图片ping、JSONP和CORS跨域
  8. Dictionary使用
  9. ASP.NET服务器控件使用之MultiView和View
  10. php中命名空间的使用