private IEnumerator DownloadProcess(DownloadSetting setting, bool useCache) { string localFilePath = localCachePath + "/" + setting.CacheRelativePath; if (useCache) { //ローカルにファイルがあるか? if (FileUtility.Exists(localFilePath)) { // キャッシュファイルと時刻比較して同じならそのファイルを読み込む if (FileUtility.IsSameLastUpdateTime(localFilePath, setting.LastUpdateTime)) { var assets = FileUtility.ReadFromFileWith3DES(localFilePath); if (assets != null) { if (setting.OnProgress != null) { setting.OnProgress(1.0f); } if (setting.OnLoad != null) { setting.OnLoad(true, assets); } yield break; } } else { FileUtility.Delete(localFilePath); } } } WWW www = new WWW(urlBuilder(setting.RelativeURL)); while (!www.isDone) { if (setting.OnProgress != null) { setting.OnProgress(www.progress); } yield return(null); } //失敗 if ((www == null) || (www.error != null)) { if (setting.OnError != null) { setting.OnError((www == null) ? "" : www.error); } //成功 } else { if (setting.OnProgress != null) { setting.OnProgress(1.0f); } if (setting.OnLoad != null) { setting.OnLoad(false, www.bytes); } if (useCache) { //キャッシュ保存 FileUtility.WriteToFileWith3DES(www.bytes, localFilePath); FileUtility.Touch(localFilePath, setting.LastUpdateTime); } } if (www != null) { www.Dispose(); } }