using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class DownloadHander
{
   public bool isFinish
   {
      get
      {
         if (HttpDownloadBasic == null)
         {
            return false;
         }

         return HttpDownloadBasic.isFinish;
      }
   }

   public float progressRate
   {
      get
      {
         if (UnityWebRequestAsyncOperation == null)
         {
            return 0;
         }
         return UnityWebRequestAsyncOperation.progress;
      }
   }
   public float maxSize;
   public byte[] Data{
      get
      {
         if (UnityWebRequestAsyncOperation == null||UnityWebRequestAsyncOperation.webRequest.result!=UnityWebRequest.Result.Success)
         {
            return null;
         }

         if (UnityWebRequestAsyncOperation.webRequest.downloadHandler is DownloadHandlerFile)
         {
            return null;
         }

         return UnityWebRequestAsyncOperation.webRequest.downloadHandler.data;
      }
   }
   public string Text{
      get
      {
        
         if (UnityWebRequestAsyncOperation == null)
         {
            return "";
         }
         return UnityWebRequestAsyncOperation.webRequest.downloadHandler.text;
      }
   }

   public HttpDownloadBasic HttpDownloadBasic;
   public System.Action<DownloadHander> OnFinishCallBack;
   public UnityWebRequestAsyncOperation UnityWebRequestAsyncOperation;
}
