Exemple #1
0
 private void LoadLocalAssetInfos()
 {
     for (int i = 0; i < m_changedInfos.Count; i++)
     {
         var    fileStream = ResourcesManager.LoadStream(m_changedInfos[i] + "/info");
         byte[] bytes      = new byte[fileStream.Length];
         fileStream.Read(bytes, 0, bytes.Length);
         AssetInfos localAssetInfos = ProtobufUtility.Deserialize <AssetInfos>(bytes);
         m_localChangedAssetInfos.Add(localAssetInfos.category, localAssetInfos);
         fileStream.Read(bytes, 0, bytes.Length);
         fileStream.Close();
         fileStream.Dispose();
         fileStream = null;
     }
 }
Exemple #2
0
        private AssetInfos LoadLocalAssetInfo(string category)
        {
            var bytes = ResourcesManager.LoadBytes(category + "/info");

            return(ProtobufUtility.Deserialize <AssetInfos>(bytes));
        }
Exemple #3
0
 private void RemoteChangeInfo(string hostUrl, List <string> urls, List <string> failedInfos, Dictionary <string, AssetInfos> infos)
 {
     for (int i = 0; i < urls.Count; i++)
     {
         string          url = hostUrl + urls[i] + "/info";
         UnityWebRequest www = UnityWebRequest.Get(url);
         www.disposeDownloadHandlerOnDispose = true;
         www.chunkedTransfer = true;
         var request = www.SendWebRequest();
         request.completed += (obj) =>
         {
             m_infosCount--;
             var async = obj as UnityWebRequestAsyncOperation;
             var w     = async.webRequest;
             if (w.isNetworkError)
             {
                 if (!failedInfos.Contains(w.url))
                 {
                     failedInfos.Add(w.url);
                 }
                 w.Dispose();
             }
             else
             {
                 if (failedInfos.Contains(w.url))
                 {
                     failedInfos.Remove(w.url);
                 }
                 AssetInfos remoteAssetInfos = ProtobufUtility.Deserialize <AssetInfos>(w.downloadHandler.data);
                 infos.Add(remoteAssetInfos.category, remoteAssetInfos);
                 if (m_infosCount <= 0)
                 {
                     m_infosCount = m_failedChangedInfosUrl.Count + m_failedAddInfosUrl.Count;
                     if (m_infosCount > 0)
                     {
                         m_reconnectCount--;
                         if (m_reconnectCount < 0)
                         {
                             if (remoteChangeInfoNetworkErrorHandler != null)
                             {
                                 remoteChangeInfoNetworkErrorHandler(w.error);
                             }
                             w.Dispose();
                             return;
                         }
                         RemoteChangeInfo(hostUrl, m_changedInfos, m_failedChangedInfosUrl, m_remoteChangedAssetInfos);
                         RemoteChangeInfo(hostUrl, m_addInfos, m_failedAddInfosUrl, m_remoteAddAssetInfos);
                     }
                     CompareWaitDownloads();
                     if (needDownloadHandler != null)
                     {
                         needDownloadHandler(m_waitDownloadSize);
                     }
                     else if (downloadCompletedHandler != null)
                     {
                         downloadCompletedHandler();
                     }
                     else
                     {
                         UnityEngine.Debug.LogError("must add complete handler");
                     }
                 }
                 w.Dispose();
             }
         };
     }
 }