DataDownLoadHandler.cs 976 B

12345678910111213141516171819202122232425262728293031323334
  1. using MRStore.Util;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.Networking;
  7. namespace XRTool.Util
  8. {
  9. /// <summary>
  10. /// 自定义下载器
  11. /// 支持大文件断点续传
  12. /// </summary>
  13. public class DataDownLoadHandler : DownloadHandlerScript
  14. {
  15. /// <summary>
  16. /// 接收到数据
  17. /// </summary>
  18. public event Action<byte[], int> OnReceiveData;
  19. /// <summary>
  20. /// 接收数据
  21. /// </summary>
  22. /// <param name="data"></param>
  23. /// <param name="dataLength"></param>
  24. /// <returns></returns>
  25. protected override bool ReceiveData(byte[] data, int dataLength)
  26. {
  27. if (data != null && data.Length > 0)
  28. {
  29. OnReceiveData?.Invoke(data, dataLength);
  30. }
  31. return base.ReceiveData(data, dataLength);
  32. }
  33. }
  34. }