예제 #1
0
 public IEnumerator CopyAssets(string[] keys)
 {
     foreach (string item in keys)
     {
         yield return(StartCoroutine(WebUtil.Download($"{"file:///"}{PathUtil.GetPath(PathType.StreamingAssetsPath, "Res", PathUtil.GetPlatformForAssetBundle())}/{item}", (byte[] bytes) =>
         {
             FileUtil.SaveAsset(PathUtil.GetPath(PathType.PersistentDataPath, "Res", PathUtil.GetPlatformForAssetBundle()), item, bytes);
             currentCopyCount += 1;
             Message?.Invoke($"初始化资源 {currentCopyCount} / {copyCount}");
             CopyProgress?.Invoke(currentCopyCount, copyCount);
         })));
     }
     //更新资源
     UpdateAssets(string.Empty);
 }
예제 #2
0
 public void InitAssets(Action <string> message = null, Action <int, int> copyProgress = null, Action <int, int> downloadProgress = null, Action <int, int> checkProgress = null, Action complete = null, Action <DownloadData, string> error = null)
 {
     Message          = message;
     CopyProgress     = copyProgress;
     DownloadProgress = downloadProgress;
     CheckProgress    = checkProgress;
     Complete         = complete;
     Error            = error;
     if (File.Exists($"{PathUtil.GetPath(PathType.PersistentDataPath, "Res", PathUtil.GetPlatformForAssetBundle())}/AssetBundleConfig.json"))
     {
         byte[] bytes = FileUtil.GetAsset($"{PathUtil.GetPath(PathType.PersistentDataPath, "Res", PathUtil.GetPlatformForAssetBundle())}/AssetBundleConfig.json");
         localAssetBundleConfig = JsonUtil.ToObject <AssetBundleConfig>(bytes.GetString());
         //更新资源
         UpdateAssets(string.Empty);
         return;
     }
     else
     {
         StartCoroutine(WebUtil.Download($"{"file:///"}{PathUtil.GetPath(PathType.StreamingAssetsPath, "Res", PathUtil.GetPlatformForAssetBundle())}/AssetBundleConfig.json", InitAssets, UpdateAssets));
     }
 }
예제 #3
0
파일: AudioManager.cs 프로젝트: 404Lcc/Lcc
 public void LoadAudio(string audio, AudioType type, Action <AudioClip> callback)
 {
     StartCoroutine(WebUtil.Download(audio, type, callback));
 }