Unity3D压缩和解压缩文件
生活随笔
收集整理的這篇文章主要介紹了
Unity3D压缩和解压缩文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天試了試,在Unity不能用C# IO類里的壓縮和解壓縮,看了論壇里的一些討論,就想著能不能用第三方的壓縮和解壓縮動態庫。
于是乎就下了一個Ionic.Zip.dll。然后,然后就沒有然后了。
Compression類:
using UnityEngine; using System.Collections; using System.IO.Compression; using System.IO; using Ionic.Zip;public class Compression : MonoBehaviour {string path1;string path2;void Start () {path1 = Application.dataPath + "/test";path2 = Application.dataPath + "/test.txt";string FileName = System.DateTime.Now.Ticks.ToString();Debug.Log(FileName);//壓縮using (ZipFile zip = new ZipFile(Application.dataPath + "/" + FileName + ".zip")) { //設置密碼 zip.Password = "abc"; //壓縮文件夾zip.AddDirectory(path1,"test");//壓縮文件zip.AddFile(path2,""); //保存zip.Save();}}//其他方法提示//刪除文件//zip.RemoveEntry();//解壓文件//zip[text.txt].Extract(path1); }
如果你覺得這個有用的話,不妨研究研究。
工程地址:http://www.vdisk.cn/down/index/14599121
總結
以上是生活随笔為你收集整理的Unity3D压缩和解压缩文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 实时游戏对战引擎MatchVS,我的对战
- 下一篇: 神经网络利用哪种算法将损失函数的值降到最