DownloadHander.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5. public class DownloadHander
  6. {
  7. public bool isFinish
  8. {
  9. get
  10. {
  11. if (HttpDownloadBasic == null)
  12. {
  13. return false;
  14. }
  15. return HttpDownloadBasic.isFinish;
  16. }
  17. }
  18. public float progressRate
  19. {
  20. get
  21. {
  22. if (UnityWebRequestAsyncOperation == null)
  23. {
  24. return 0;
  25. }
  26. return UnityWebRequestAsyncOperation.progress;
  27. }
  28. }
  29. public float maxSize;
  30. public byte[] Data{
  31. get
  32. {
  33. if (UnityWebRequestAsyncOperation == null||UnityWebRequestAsyncOperation.webRequest.result!=UnityWebRequest.Result.Success)
  34. {
  35. return null;
  36. }
  37. if (UnityWebRequestAsyncOperation.webRequest.downloadHandler is DownloadHandlerFile)
  38. {
  39. return null;
  40. }
  41. return UnityWebRequestAsyncOperation.webRequest.downloadHandler.data;
  42. }
  43. }
  44. public string Text{
  45. get
  46. {
  47. if (UnityWebRequestAsyncOperation == null)
  48. {
  49. return "";
  50. }
  51. return UnityWebRequestAsyncOperation.webRequest.downloadHandler.text;
  52. }
  53. }
  54. public HttpDownloadBasic HttpDownloadBasic;
  55. public System.Action<DownloadHander> OnFinishCallBack;
  56. public UnityWebRequestAsyncOperation UnityWebRequestAsyncOperation;
  57. }