UnityWebFileRequester.cs 919 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine.Networking;
  5. using UnityEngine;
  6. namespace YooAsset
  7. {
  8. internal class UnityWebFileRequester : UnityWebRequesterBase
  9. {
  10. /// <summary>
  11. /// 发送GET请求
  12. /// </summary>
  13. public void SendRequest(string url, string fileSavePath, int timeout = 60)
  14. {
  15. if (_webRequest == null)
  16. {
  17. URL = url;
  18. ResetTimeout(timeout);
  19. _webRequest = DownloadHelper.NewRequest(URL);
  20. DownloadHandlerFile handler = new DownloadHandlerFile(fileSavePath);
  21. handler.removeFileOnAbort = true;
  22. _webRequest.downloadHandler = handler;
  23. _webRequest.disposeDownloadHandlerOnDispose = true;
  24. _operationHandle = _webRequest.SendWebRequest();
  25. }
  26. }
  27. }
  28. }