public void OpenFile()
    {
        FileOpenDialog dialog = new FileOpenDialog();

        dialog.structSize = Marshal.SizeOf(dialog);

        dialog.filter = "exe files\0*.exe\0All Files\0*.*\0\0";

        dialog.file = new string(new char[256]);

        dialog.maxFile = dialog.file.Length;

        dialog.fileTitle = new string(new char[64]);

        dialog.maxFileTitle = dialog.fileTitle.Length;

        dialog.initialDir = UnityEngine.Application.dataPath;  //默认路径

        dialog.title = "Open File Dialog";

        dialog.defExt = "exe";                                                         //显示文件的类型
        //注意一下项目不一定要全选 但是0x00000008项不要缺少
        dialog.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR

        if (DialogShow.GetOpenFileName(dialog))
        {
            Debug.Log(dialog.file);
        }
    }
示例#2
0
    public static string OpenFile(string types)
    {
        FileOpenDialog dialog = new FileOpenDialog();

        dialog.structSize = Marshal.SizeOf(dialog);
        string[] type = types.Split('|');

        dialog.filter = "";
        for (int i = 0; i < type.Length; ++i)
        {
            dialog.filter += type[i] + " file\0*." + type[i];
            if (i < type.Length - 1)
            {
                dialog.filter += "\0";
            }
        }
        dialog.filter += "\0All Files\0*.*\0\0";

        dialog.file = new string(new char[256]);

        dialog.maxFile = dialog.file.Length;

        dialog.fileTitle = new string(new char[64]);

        dialog.maxFileTitle = dialog.fileTitle.Length;

        dialog.initialDir = UnityEngine.Application.dataPath;  //默认路径

        dialog.title = "Open File Dialog";

        dialog.defExt = type[0];
        dialog.flags  = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;

        if (DialogShow.GetOpenFileName(dialog))
        {
            //  Debug.Log(dialog.file);
            return(dialog.file);
        }
        return("");
    }
示例#3
0
    // outPath: Resource 下的路径
    private static void ImportVideoFile(string outDir, string prefix)
    {
        FileOpenDialog dialog = new FileOpenDialog();

        dialog.structSize = Marshal.SizeOf(dialog);

        dialog.filter = ".mp4\0*.mp4\0webm文件\0*.webm";

        dialog.file = new string(new char[256]);

        dialog.maxFile = dialog.file.Length;

        dialog.fileTitle = new string(new char[64]);

        dialog.maxFileTitle = dialog.fileTitle.Length;

        dialog.initialDir = UnityEngine.Application.streamingAssetsPath;  //默认路径

        dialog.title = "Open File Dialog";

        //dialog.defExt = "mp4";//显示文件的类型
        //注意一下项目不一定要全选 但是0x00000008项不要缺少
        dialog.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;  //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR

        if (DialogShow.GetOpenFileName(dialog))
        {
            string destDir   = Application.streamingAssetsPath + "/Resources/" + outDir + "/Videos/";
            string videoName = prefix + "_" + dialog.fileTitle;
            File.Copy(dialog.file, destDir + videoName, true);
            Debug.Log("复制成功:" + destDir + videoName);

            GameObject.Find("GetImage").GetComponent <GetImage>().GeneratePreviewImage(
                ResAPI.Instance.FillVideoPath(videoName),
                Application.streamingAssetsPath + "/Resources/" + outDir + "/Thumbnails/"
                );
        }
    }
示例#4
0
    private static void ImportImageFile(string outDir, string prefix)
    {
        FileOpenDialog dialog = new FileOpenDialog();

        dialog.structSize   = Marshal.SizeOf(dialog);
        dialog.filter       = "png\0*.png\0jpg\0*.jpg";
        dialog.file         = new string(new char[256]);
        dialog.maxFile      = dialog.file.Length;
        dialog.fileTitle    = new string(new char[64]);
        dialog.maxFileTitle = dialog.fileTitle.Length;
        dialog.initialDir   = Application.streamingAssetsPath;                                //默认路径
        dialog.title        = "Open File Dialog";
        dialog.defExt       = "png";                                                          //显示文件的类型
        dialog.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR

        if (DialogShow.GetOpenFileName(dialog))
        {
            string destDir  = Path.Combine(Application.streamingAssetsPath, "Resources", outDir, "Images/");
            string name     = prefix + "_" + dialog.fileTitle /*+ ".png"*/;
            string fullPath = Path.Combine(destDir, name);
            File.Copy(dialog.file, fullPath, true);
            Debug.Log("复制成功:" + fullPath);
        }
    }