Exemplo n.º 1
0
 /// <summary>
 /// 下载大文件优势更大
 /// </summary>
 public static void DownloadFileWithWebRequest(string serverUrl, string saveFile, Action <string> onDownload, Action <float> onProgress = null)
 {
     WWWUtil.GetFromWebRequest(serverUrl).SubscribeWithProgress(x =>
     {
         byte[] arr  = x.webRequest.downloadHandler.data;//如果是www.bytes,文件太大的情况下会卡几秒
         bool sucess = SaveFile(saveFile, arr);
         if (sucess)
         {
             if (onDownload != null)
             {
                 onDownload("download sucess");
             }
         }
         else
         {
             if (onDownload != null)
             {
                 onDownload("save file error");
             }
         }
     }
                                                                , error =>
     {
         if (onDownload != null)
         {
             onDownload(error.error);
         }
     }, progress =>
     {
         if (onProgress != null)
         {
             onProgress(progress.webRequest.downloadProgress);
         }
     });
 }
Exemplo n.º 2
0
 static int QPYX_GetFromWebRequest_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 1)
         {
             string       QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 1);
             WWWOperation QPYX_o_YXQP    = WWWUtil.GetFromWebRequest(QPYX_arg0_YXQP);
             ToLua.PushObject(L_YXQP, QPYX_o_YXQP);
             return(1);
         }
         else if (QPYX_count_YXQP == 2)
         {
             string       QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 1);
             float        QPYX_arg1_YXQP = (float)LuaDLL.luaL_checknumber(L_YXQP, 2);
             WWWOperation QPYX_o_YXQP    = WWWUtil.GetFromWebRequest(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
             ToLua.PushObject(L_YXQP, QPYX_o_YXQP);
             return(1);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: WWWUtil.GetFromWebRequest"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }