VirtualFramework/Assets/Scripts/Tools/ChinarFileController.cs

66 lines
2.0 KiB
C#
Raw Permalink Normal View History

2025-03-06 13:28:21 +08:00
using UnityEngine;
using System.Runtime.InteropServices;
using System;
/// <summary>
/// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ƽű<C6BD>
/// </summary>
public class ChinarFileController : MonoBehaviour
{
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
/// </summary>
public static string OpenProject()
{
string originalDir = Environment.CurrentDirectory;
string filepath = string.Empty;
OpenFileDlg pth = new OpenFileDlg();
pth.structSize = Marshal.SizeOf(pth);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>Ƴ<EFBFBD>ĩβ<C4A9><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>
//pth.filter = @"All Files (*.*)|*.jpg";
pth.file = new string(new char[256]);
pth.maxFile = pth.file.Length;
pth.fileTitle = new string(new char[64]);
pth.maxFileTitle = pth.fileTitle.Length;
pth.initialDir = Application.dataPath.Replace("/", "\\") + "\\Resources";
pth.title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ";
pth.defExt = "dat";
// <20><><EFBFBD><EFBFBD>Flags<67><73><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD>ѡ<EFBFBD>
pth.flags = 0x00080000 | 0x00001000 | 0x00000800; // OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST
if (OpenFileDialog.GetOpenFileName(pth))
{
filepath = pth.file;
}
Environment.CurrentDirectory = originalDir;
return filepath;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ
/// </summary>
public static string SaveProject(string ext)
{
string filepath = string.Empty;
SaveFileDlg pth = new SaveFileDlg();
pth.structSize = Marshal.SizeOf(pth);
pth.filter = "All files (*.*)|*.*";
pth.file = new string(new char[256]);
pth.maxFile = pth.file.Length;
pth.fileTitle = new string(new char[64]);
pth.maxFileTitle = pth.fileTitle.Length;
pth.initialDir = Application.dataPath; //Ĭ<><C4AC>·<EFBFBD><C2B7>
pth.title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ";
pth.defExt = ext;
pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
if (SaveFileDialog.GetSaveFileName(pth))
{
filepath = pth.file; //ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>;
}
return filepath;
}
}