真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

如何實(shí)現(xiàn)UnityC#GetSaveFileName()

如何實(shí)現(xiàn)Unity C# GetSaveFileName()?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。

站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到西工網(wǎng)站設(shè)計(jì)與西工網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、國(guó)際域名空間、網(wǎng)絡(luò)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋西工地區(qū)。

先放個(gè)效果圖:

如何實(shí)現(xiàn)Unity C# GetSaveFileName()

首先需要定義一個(gè)OpenFileName的類:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

public class OpenFileName
{
	public int structSize = 0;
	public IntPtr dlgOwner = IntPtr.Zero;
	public IntPtr instance = IntPtr.Zero;
	public String filter = null;
	public String customFilter = null;
	public int maxCustFilter = 0;
	public int filterIndex = 0;
	public String file = null;
	public int maxFile = 0;
	public String fileTitle = null;
	public int maxFileTitle = 0;
	public String initialDir = null;
	public String title = null;
	public int flags = 0;
	public short fileOffset = 0;
	public short fileExtension = 0;
	public String defExt = null;
	public IntPtr custData = IntPtr.Zero;
	public IntPtr hook = IntPtr.Zero;
	public String templateName = null;
	public IntPtr reservedPtr = IntPtr.Zero;
	public int reservedInt = 0;
	public int flagsEx = 0;
}

當(dāng)然,也不是都用到了,只用到了一小部分,有性趣的童鞋可以個(gè)性化一下保存對(duì)話框,

然后是最重要的委托GetSaveName()方法:

public class DllUse
{
	[DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
	public static extern bool GetSaveFileName([In, Out] OpenFileName ofn);
}

擋擋擋,最后調(diào)用一下即可:

public static void OpenDialog(Action onSave)
    {
        OpenFileName ofn = new OpenFileName();
        ofn.structSize = Marshal.SizeOf(ofn);
    
        ofn.filter = "Excel (*.xls)\0*.xls\0\0";
        ofn.file = new string(new char[256]);
        ofn.maxFile = ofn.file.Length;
        ofn.fileTitle = new string(new char[64]);
        ofn.maxFileTitle = ofn.fileTitle.Length;
        ofn.initialDir = UnityEngine.Application.dataPath;//默認(rèn)路徑ofn.title = "保存文件";
        ofn.defExt = ".xls";//顯示文件的類型ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;if (DllTest.GetSaveFileName(ofn))
        {
            dosomething();string Savepath = Path.GetDirectoryName (ofn.file);
            Process.Start (Savepath);
        }
    }

如何實(shí)現(xiàn)Unity C# GetSaveFileName()

如何實(shí)現(xiàn)Unity C# GetSaveFileName()

看完上述內(nèi)容,你們掌握如何實(shí)現(xiàn)Unity C# GetSaveFileName()的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!


文章標(biāo)題:如何實(shí)現(xiàn)UnityC#GetSaveFileName()
瀏覽地址:http://weahome.cn/article/gsegpi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部