unity3d 压缩文件夹和压缩文件
直接開(kāi)始,不扯淡
1:下載名字為《 ? Ionic.zip? ? 》的壓縮包,將里面的《 ? ?Ionic.Zip.dll? ? 》放到unity3d的Plugins文件夾下。如果沒(méi)有此文件夾,自己創(chuàng)建
2:腳本操作
using UnityEngine;
using System.Collections;
using Ionic.Zip;
public class YaSuo : MonoBehaviour {
? ? //路徑
? ? string WenJianJiaPath; ?//文件夾
? ? //string FilePath; ? ? ?//文件
// Use this for initialization
void Start () {
? ? ? ? //設(shè)置文件夾的路徑
? ? ? ? WenJianJiaPath = Application.dataPath + "/Sound";
? ? ? ? //文件路徑
? ? ? ? //FilePath = Application.dataPath + "/Sound/New Material.mat";
? ? ? ? //壓縮包的名字
? ? ? ? string FileName = "XiaoBaiYaSouFile";
? ? ? ? //輸出
? ? ? ? print(FileName);
? ? ? ? //開(kāi)始?jí)嚎s
? ? ? ? using(ZipFile zip = new ZipFile(Application.dataPath + "/" + FileName + ".zip")){
? ? ? ? ? ? //設(shè)置密碼
? ? ? ? ? ? zip.Password = "000";
? ? ? ? ? ? //壓縮文件夾
? ? ? ? ? ? zip.AddDirectory(WenJianJiaPath, "Sound");
? ? ? ? ? ? //壓縮文件
? ? ? ? ? ? //zip.AddFile(FilePath,"");
? ? ? ? ? ? //保存
? ? ? ? ? ? zip.Save();
? ? ? ? ? ? //其他方法提示
? ? ? ? ? ? //刪除文件
? ? ? ? ? ? //zip.RemoveEntry();
? ? ? ? ? ? //解壓文件
? ? ? ? ? ? //zip[text.text].Extract(SoundPath);
? ? ? ? }
}
}
?3:此腳本隨便拖到一個(gè)物體上。
4:創(chuàng)建一個(gè)Sound的文件夾,因?yàn)槟_本上面我填寫(xiě)的就是Sound文件夾。zip.AddDirectory(WenJianJiaPath, "Sound");
5:運(yùn)行程序。
溫馨提示:
如果有中文路徑,請(qǐng)將 ?using(ZipFile zip = new ZipFile(Application.dataPath + "/" + FileName + ".zip")) 改成?using (ZipFile zip = new ZipFile(System.Text.Encoding.Default))
然后將??zip.Save(); 改成 ?zip.Save(Application.dataPath + "/" + FileName + ".zip");?
這樣就完美的解決了發(fā)布以后中文文件夾名字變成亂碼的情況啦。
總結(jié)
以上是生活随笔為你收集整理的unity3d 压缩文件夹和压缩文件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 智能手环guard日志获取-兔盯云
- 下一篇: unity3d api 中文文档_uni