Ejemplo n.º 1
0
        /// <summary>
        /// 把网络下载过来的文件 改成可以正式使用的文件
        /// </summary>
        private void ChangeFileToUse()
        {
            if (isDownloadingFile)
            {
                return;
            }

            ResourcesInfoData localResourceInfoData = new ResourcesInfoData();

            if (File.Exists(AssetBundleFilePath.ServerExtensionDataPath + "ResourceInfoData.csv"))
            {
                localResourceInfoData.InitFromPath(AssetBundleFilePath.ServerExtensionDataPath + "ResourceInfoData.csv");
            }
            else
            {
                localResourceInfoData.InitFromResource();
            }

            int dataRow = localResourceInfoData.GetDataRow();

            for (int i = 1; i <= dataRow; ++i)
            {
                string bundleName = localResourceInfoData.GetBundleName(i);
                string path       = AssetBundleFilePath.ServerExtensionDataPath + bundleName + ".temp";
                if (File.Exists(path))
                {
                    string outFile = AssetBundleFilePath.ServerExtensionDataPath + bundleName;
                    if (File.Exists(outFile))
                    {
                        File.Delete(outFile);
                    }
                    File.Move(path, outFile);
                }
            }
        }
Ejemplo n.º 2
0
        public bool IsAllAssetsIsReady()
        {
            ResourcesInfoData localResourceInfoData = new ResourcesInfoData();

            if (File.Exists(AssetBundleFilePath.ServerExtensionDataPath + "ResourceInfoData.csv"))
            {
                localResourceInfoData.InitFromPath(AssetBundleFilePath.ServerExtensionDataPath + "ResourceInfoData.csv");
            }
            else
            {
                return(false);
            }

            int dataRow = localResourceInfoData.GetDataRow();

            for (int i = 1; i <= dataRow; ++i)
            {
                string bundleName = localResourceInfoData.GetBundleName(i);
                if (!File.Exists(AssetBundleFilePath.ServerExtensionDataPath + bundleName))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///  对比本地和服务器上的ResourceInfoData
        /// 确定要下载的文件
        /// </summary>
        /// <returns>The compare info file.</returns>
        IEnumerator IECompareInfoFile()
        {
            WWW getAssetInfoW = new WWW(serverAddr + "ResourceInfoData.csv");

            yield return(getAssetInfoW);

            if (getAssetInfoW.error != null)
            {
                Debug.LogError("can not connect to server");
                yield  break;
            }


            string infoText = getAssetInfoW.text;

            serverResourceInfoData = new ResourcesInfoData();
            serverResourceInfoData.InitFromString(infoText);


            ResourcesInfoData localResourceInfoData = new ResourcesInfoData();

            if (File.Exists(AssetBundleFilePath.ServerExtensionDataPath + "ResourceInfoData.csv"))
            {
                localResourceInfoData.InitFromPath(AssetBundleFilePath.ServerExtensionDataPath + "ResourceInfoData.csv");
            }
            else
            {
                localResourceInfoData.InitFromResource();
            }


            downLoadFileList.Clear();
            downingFileCount = 0;
            for (int i = 1; i <= serverResourceInfoData.GetDataRow(); ++i)
            {
                string bundleName        = serverResourceInfoData.GetBundleName(i);
                int    serverVersionCode = serverResourceInfoData.GetVersionCode(i);

                int localVerCode = localResourceInfoData.GetVersionCodeByBundleName(bundleName);
                if (localVerCode < 0)
                {
                    downLoadFileList.Add(bundleName);
                }
                else if (localVerCode < serverVersionCode)
                {
                    downLoadFileList.Add(bundleName);
                }
                Debug.Log(bundleName + " " + serverVersionCode + " " + localVerCode);
            }

            if (downLoadFileList.Count > 0)
            {
                isDownloadingFile  = true;
                downloadFileIndex  = 1;
                totalFileCount     = downLoadFileList.Count;
                downloadRetryCount = 0;
                DownLoadNextFile();
            }
            else
            {
                Debug.Log("ALL file had updated");
                EndHotFixUpdate();
            }
        }