Ejemplo n.º 1
0
        public void VerifyAssetbundleVersionFile(string abType, Action <bool> callback)
        {
            ClearData();

            _serverAssetbundlePath = UrlPacks.GetResUrl() + abType + "/";

            //加载服务器的version 文件
            StartCoroutine(DownLoad(_serverAssetbundlePath + VersionFile, wwwServerVersionData =>
            {
                //记录服务器version文件MD5
                ParseVersionFile(wwwServerVersionData.text, _serverResVersion);

                //加载客户端的version文件
                StartCoroutine(DownLoad(_persistentResUrl + abType + "/" + VersionFile, wwwPersistentVersionData =>
                {
                    //记录沙盒路径下的version文件的MD5
                    ParseVersionFile(wwwPersistentVersionData.text, _persistentResVersion);

                    //计算出需要重新加载的资源
                    CompareVersion();

                    callback(_needUpdateLocalVersionFile);
                }));
            }));
        }
Ejemplo n.º 2
0
        private void InitOthers()
        {
            GameObject go = new GameObject("UrlPacks");

            DontDestroyOnLoad(go); //防止销毁自己
            UrlPacks url = go.AddComponent <UrlPacks>();

            url.InitUrls((success) =>
            {
                if (success)
                {
#if !SkipAssetBundles
                    io.download.InitRelativePath();
                    io.ui.ShowLocalUI("LocalLoading", true);
                    io.res.LoadAssetbundle(AssetBundleType.UI.ToString());
#else
                    Messenger.Broadcast(XEvent.FinishLoading);
#endif
                }
                else
                {
                    Debug.LogError("无法解析URL数据。");
                }
            });
        }
Ejemplo n.º 3
0
 //初始化路径
 public void InitRelativePath()
 {
     if (Application.isEditor)
     {
         _persistentResUrl = "file://" + Environment.CurrentDirectory.Replace("\\", "/") + "/Assets/StreamingAssets/AssetBundles/";
         PersistentResPath = Environment.CurrentDirectory.Replace("\\", "/") + "/Assets/StreamingAssets/AssetBundles/";
         _serverResUrl     = UrlPacks.GetResUrl();
     }
     else if (Application.isMobilePlatform)
     {
         _persistentResUrl = "file://" + Application.persistentDataPath + "/AssetBundles/";
         PersistentResPath = Application.persistentDataPath + "/AssetBundles/";
         _serverResUrl     = UrlPacks.GetResUrl();
     }
     else
     {
         _persistentResUrl = "file://" + Application.streamingAssetsPath + "/AssetBundles/";
         PersistentResPath = Application.streamingAssetsPath + "/AssetBundles/";
     }
 }
Ejemplo n.º 4
0
        public void DownLoadAssetbundle(string abType, Action callback)
        {
            if (_isLoadingAssetBundle)
            {
                Debug.Log("请等待资源加载完成");
                return;
            }

            _callback = callback;

            _isLoadingAssetBundle = true;

            _curAssetbundleType = abType;

            _serverAssetbundlePath = UrlPacks.GetResUrl() + _curAssetbundleType + "/";

            ClearData();

            VerifyAssetbundleVersionFile(abType, needUpdate =>
            {
                DownLoadRes();
            });
        }