zoukankan      html  css  js  c++  java
  • unity3d下载Obb分包文件

    原地址:http://www.cnblogs.com/88999660/p/3678180.html

    下载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*100).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,0);
                
                yield return www;
                
                if(www.error == null){
                    Application.LoadLevel("Menu");
                }
            }
        }
    }
    复制代码
  • 相关阅读:
    tcpdump 命令的常用选项:一
    Centos系统中 Systemd 的Unit文件配置说明
    如何使用PowerShell获取物理磁盘的信息
    tcpdump 命令的常用选项:二
    Google报告:大量被入侵的 Google Cloud 实例被用来挖掘加密货币
    Ubuntu中使用pdftk合并、分离PDF文档等操作
    tcpdump 命令的常用选项:三
    优麒麟Ubuntu Kylin 20.04 Pro SP1 上线
    为SSH登录设置电子邮件提醒
    图片上传并显示(兼容ie),图片大小判断
  • 原文地址:https://www.cnblogs.com/123ing/p/3703864.html
Copyright © 2011-2022 走看看