示例#1
0
    public void RequestVersion()
    {
        panel_alert.SetActive(false);
        text_msg.text = "检查更新";
        UpdateManager.GetInstance().RequestVersion(delegate(WWW www){
            if (www.error != null)
            {
                Debug.LogError("downloading error! " + www.error);
                panel_alert.SetActive(true);
                text_msg.text = "更新失败";
                return;
            }

            bool bNeedUpdate = UpdateManager.GetInstance().CompareVersion(www.text);

            // download resources
            if (bNeedUpdate)
            {
                string[] files = UpdateManager.GetInstance().UpdateFiles;
                int count      = 1;
                AssetBundleManager.GetInstance().SetDownloadCallback(delegate {
                    text_msg.text = string.Format("更新资源({0}/{1})", count++, files.Length);
                });
                for (int i = 0; i < files.Length; i++)
                {
                    AssetBundleManager.AddDownloadAssetBundle(files[i]);
                }
                bDownloading = true;
            }
            else
            {
                // use local
                OnDownloadFinish();
            }
        });
    }