Beispiel #1
0
 private bool CheckAsset(string fileName)
 {
     if (CrossPlatformFile.Exists(GetTemporaryPathFileName(fileName)))
     {
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        protected virtual void SaveBinaryAsset(SwrveAssetsQueueItem item, WWW www)
        {
            byte[] bytes = www.bytes;
            string text  = SwrveHelper.sha1(bytes);

            if (text == item.Digest)
            {
                string temporaryPathFileName = this.GetTemporaryPathFileName(item.Name);
                SwrveLog.Log("Saving to " + temporaryPathFileName);
                CrossPlatformFile.SaveBytes(temporaryPathFileName, bytes);
                this.AssetsOnDisk.Add(item.Name);
            }
            else
            {
                SwrveLog.Log("Error downloading binary assetItem:" + item.Name + ". Did not match digest:" + text);
            }
        }
Beispiel #3
0
        protected virtual void SaveBinaryAsset(SwrveAssetsQueueItem item, UnityWebRequest www)
        {
            byte[] bytes = www.downloadHandler.data;
            string sha1  = SwrveHelper.sha1(bytes);

            if (sha1 == item.Digest)
            {
                string filePath = GetTemporaryPathFileName(item.Name);
                SwrveLog.Log("Saving to " + filePath);
                CrossPlatformFile.SaveBytes(filePath, bytes);
                bytes = null;
                AssetsOnDisk.Add(item.Name);
            }
            else
            {
                SwrveLog.Log("Error downloading binary assetItem:" + item.Name + ". Did not match digest:" + sha1);
            }
        }
Beispiel #4
0
        protected virtual void SaveImageAsset(SwrveAssetsQueueItem item, WWW www)
        {
            Texture2D texture = www.texture;

            if (texture != null)
            {
                byte[] bytes = www.bytes;
                string text  = SwrveHelper.sha1(bytes);
                if (text == item.Digest)
                {
                    byte[] bytes2 = texture.EncodeToPNG();
                    string temporaryPathFileName = this.GetTemporaryPathFileName(item.Name);
                    SwrveLog.Log("Saving to " + temporaryPathFileName);
                    CrossPlatformFile.SaveBytes(temporaryPathFileName, bytes2);
                    UnityEngine.Object.Destroy(texture);
                    this.AssetsOnDisk.Add(item.Name);
                }
                else
                {
                    SwrveLog.Log("Error downloading image assetItem:" + item.Name + ". Did not match digest:" + text);
                }
            }
        }
Beispiel #5
0
        protected virtual void SaveImageAsset(SwrveAssetsQueueItem item, UnityWebRequest www)
        {
            Texture2D loadedTexture = ((DownloadHandlerTexture)www.downloadHandler).texture;

            if (loadedTexture != null)
            {
                byte[] rawBytes = www.downloadHandler.data;
                string sha1     = SwrveHelper.sha1(rawBytes);
                if (sha1 == item.Digest)
                {
                    byte[] bytes    = loadedTexture.EncodeToPNG();
                    string filePath = GetTemporaryPathFileName(item.Name);
                    SwrveLog.Log("Saving to " + filePath);
                    CrossPlatformFile.SaveBytes(filePath, bytes);
                    bytes = null;
                    Texture2D.Destroy(loadedTexture);
                    AssetsOnDisk.Add(item.Name);
                }
                else
                {
                    SwrveLog.Log("Error downloading image assetItem:" + item.Name + ". Did not match digest:" + sha1);
                }
            }
        }
Beispiel #6
0
 private bool CheckAsset(string fileName)
 {
     return(CrossPlatformFile.Exists(this.GetTemporaryPathFileName(fileName)));
 }