Пример #1
0
    //加载头像图片
    public void OpenFile()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        ofn.filter = "图片文件(*.jpg*.png*.jpeg)\0*.jpg;*.png;*.jpeg";

        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;//默认路径

        ofn.title = "选择图片";

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

        if (WindowDll.GetOpenFileName(ofn))
        {
            this.loadingImg.SetActive(true);
            StartCoroutine(GetTexture(ofn.file));//加载图片到panle
        }
    }
Пример #2
0
    /// <summary>
    /// 打开选择文件的窗口
    /// </summary>
    /// <returns></returns>
    static public string OpenFileDisplay()
    {
        string       path = "";
        OpenFileName ofn  = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        ofn.filter = "All Files\0*.*\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;//默认路径

        ofn.title = "Open Project";

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

        if (DllTest.GetOpenFileName(ofn))
        {
            path = ofn.file;
        }
        return(path);
    }
Пример #3
0
    string  Ruta()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize   = Marshal.SizeOf(ofn);
        ofn.filter       = "Archivos de imagen\0*.*\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;                        //默认路径
        ofn.title        = "Cargar imagen";
        ofn.defExt       = "JPG";                                                   //显示文件的类型
        //注意 一下项目不一定要全选 但是0x00000008项不要缺少
        ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
        if (DllTest.GetOpenFileName(ofn))
        {
            //Debug.Log ("Selected file with full path: {0}" + ofn.file);
            return(ofn.file);
        }
        else
        {
            return("");
        }
    }
Пример #4
0
    private IEnumerator IELoadExternalAudioWebRequest2(OpenFileName file)
    {
        string _url = file.file;

        audioS.Stop();
        string _tempURL = _url.Replace(".mp3", ".wav");

        Debug.print(_tempURL);
        if (!File.Exists(_tempURL))
        {
            FileStream    _fileStream    = File.Open(_url, FileMode.Open);
            Mp3FileReader _mp3FileReader = new Mp3FileReader(_fileStream);
            WaveFileWriter.CreateWaveFile(_tempURL, _mp3FileReader);
        }
        yield return(null);

        UnityWebRequest _unityWebRequest = UnityWebRequestMultimedia.GetAudioClip(_tempURL, AudioType.WAV);

        yield return(_unityWebRequest.SendWebRequest());

        if (_unityWebRequest.isHttpError || _unityWebRequest.isNetworkError)
        {
            Debug.print(_unityWebRequest.error.ToString());
        }
        else
        {
            audioS.clip = DownloadHandlerAudioClip.GetContent(_unityWebRequest);
            Audio.ResetHighest();
            audioS.Play();
        }
    }
Пример #5
0
    public void OpenFileWin()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);
        ofn.filter     = "All Files\0*.*\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;
        string path = Application.streamingAssetsPath;

        path           = path.Replace('/', '\\');
        ofn.initialDir = path;
        ofn.title      = "Open Model";

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

        if (WindowDll.GetOpenFileName(ofn))
        {
            Debug.Log("Selected file with full path: {0}" + ofn.file);
            Path.text = ofn.file.Replace("\\", "/");
        }
    }
Пример #6
0
    IEnumerator CignetLoad()
    {
        string path = OpenFileName.ShowDialog("all", "all");

        AssetBundleCreateRequest asyncBundleRequest = AssetBundle.LoadFromFileAsync(path);

        yield return(asyncBundleRequest);

        AssetBundle localAssetBundle = asyncBundleRequest.assetBundle;

        if (localAssetBundle == null)
        {
            Debug.LogError("Failed to load AssetBundle!");
            yield break;
        }

        AssetBundleRequest assetRequest = localAssetBundle.LoadAssetAsync <GameObject>(assetName);

        yield return(assetRequest);

        GameObject prefab = assetRequest.asset as GameObject;

        Instantiate(prefab);

        localAssetBundle.Unload(false);
    }
Пример #7
0
    private void Start()
    {
        Avatar = null;

        _buttonVRM?.onClick.AddListener(async() =>
        {
            var bytes = await UniTask.Run(() => ReadBytes());

            if (bytes != null)
            {
                var context = new VRMImporterContext();

                await UniTask.Run(() => context.ParseGlb(bytes));
                var meta = context.ReadMeta(false);

                context.LoadAsync(() => OnLoaded(context));
            }
        });

        _buttonAssetBundle?.onClick.AddListener(async() =>
        {
            string path = await Task.Run(() => OpenFileName.ShowDialog("all", "."));

            //前のアバターの消去
            GameObject[] othreAvatars = GameObject.FindGameObjectsWithTag("Avatar");
            foreach (GameObject otherAvatar in othreAvatars)
            {
                Destroy(otherAvatar);
            }

            StartCoroutine(LoadBundleCoroutine(path));
        });
    }
Пример #8
0
    public override void OnInspectorGUI()
    {
        //EditorGUILayout.BeginHorizontal();

        //EditorGUILayout.EndHorizontal();

        if (GUILayout.Button("load map"))
        {
            OpenFileName ofn = new OpenFileName();
            ofn.structSize   = Marshal.SizeOf(ofn);
            ofn.filter       = "All Files\0*.*\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   = Application.dataPath;                                    //默认路径
            ofn.title        = "Open Project";
            ofn.defExt       = "bin";                                                   //显示文件的类型
            //注意 一下项目不一定要全选 但是0x00000008项不要缺少
            ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
            if (OpenWindows.GetOpenFileName(ofn))
            {
                navTools.LoadMap(ofn.file);
            }
        }

        if (GUILayout.Button("test navmesh"))
        {
            navTools.StartNavTest();
        }
    }
Пример #9
0
    public void Openfile(Text text)
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        //ofn.filter = "All Files\0*.*\0\0";
        ofn.filter = "音频文件(*.WAV*.MP3*.OGG)\0*.WAV;*.MP3;*.OGG";
        ofn.file   = new string(new char[256]);

        ofn.maxFile = ofn.file.Length;

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

        ofn.maxFileTitle = ofn.fileTitle.Length;
        string path = UnityEngine.Application.streamingAssetsPath;

        path = path.Replace('/', '\\');
        //默认路径
        ofn.initialDir = path;
        //ofn.initialDir = "D:\\MyProject\\UnityOpenCV\\Assets\\StreamingAssets";
        ofn.title = "Open Project";

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

        if (WindowDll.GetOpenFileName1(ofn))
        {
            //加载图片到panle
            StartCoroutine(WaitLoad(ofn.file, text));
            Debug.Log("Selected file with full path: {0}" + ofn.file);
        }
    }
Пример #10
0
    public void ButtonSaveProjectAsOnClick()//SaveProjectAs按钮被点击
    {
        CloseFilePanel();
        OpenFileName ofn = new OpenFileName();

        ofn.structSize   = Marshal.SizeOf(ofn);
        ofn.filter       = "项目文件(*.proj)\0*.proj";
        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   = Application.streamingAssetsPath.Replace('/', '\\');//默认路径
        ofn.title        = "另存为";
        ofn.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
        if (LocalDialog.GetSaveFileName(ofn))
        {
            if (!File.Exists(ofn.file))
            {
                ofn.file += ".proj";
                //File.Create(ofn.file);
            }
            Debug.Log("file: " + ofn.file);
            //StartCoroutine(Export3dContactPoints(ofn.file));
            saveProjectPath = ofn.file;//更新保存项目的存储路径
            Save.SaveByBin(saveProjectPath);
        }
    }
Пример #11
0
    public void ButtonExportScene()//导出场景到obj
    {
        CloseFilePanel();
        OpenFileName ofn = new OpenFileName();

        ofn.structSize   = Marshal.SizeOf(ofn);
        ofn.filter       = "Obj文件(*.obj)\0*.obj";
        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   = Application.streamingAssetsPath.Replace('/', '\\');//默认路径
        ofn.title        = "导出场景到obj";
        ofn.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
        if (LocalDialog.GetSaveFileName(ofn))
        {
            if (!File.Exists(ofn.file))
            {
                ofn.file += ".obj";
                //File.Create(ofn.file);
            }
            Debug.Log("file: " + ofn.file);
            ExportSceneToObj(ofn.file);
        }
    }
Пример #12
0
    private void CreatExcel()
    {
        OpenFileName openFileName = new OpenFileName();

        openFileName.structSize   = Marshal.SizeOf(openFileName);
        openFileName.filter       = "Excel文件(*.xlsx)\0*.xlsx";
        openFileName.file         = new string(new char[256]);
        openFileName.maxFile      = openFileName.file.Length;
        openFileName.fileTitle    = new string(new char[64]);
        openFileName.maxFileTitle = openFileName.fileTitle.Length;
        openFileName.initialDir   = Application.streamingAssetsPath.Replace('/', '\\');
        //默认路径
        openFileName.title = "导出数据";
        openFileName.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
        if (LocalDialog.GetSaveFileName(openFileName))
        {
            string   createPath = openFileName.file + ".xlsx";
            FileInfo newFile    = new FileInfo(createPath);
            if (newFile.Exists)
            {
                newFile.Delete();
                newFile = new FileInfo(createPath);
            }
            using (ExcelPackage package = new ExcelPackage(newFile))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("table1");
                //创建worksheet
                //worksheet.Column(1).Width = 30;
                //直接指定行列数进行赋值
                //worksheet.Cells[1, 1].Value = "序号";
                for (int i = 2; i <= 7; i++)
                {
                    worksheet.Cells[1, i].Value = "CH" + (i - 1);
                }
                worksheet.Cells[1, 8].Value = "时间";
                worksheet.Cells[2, 8].Value = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

                for (int i = 0; i <= 5; i++)
                {
                    for (int j = 0; j <= ReceiveData.DealDataList[i].Count - 1; j++)
                    {
                        worksheet.Cells[j + 2, 1].Value     = j + 1;
                        worksheet.Cells[j + 2, i + 2].Value = ReceiveData.DealDataList[i][j];
                    }
                    ReceiveData.DealDataList[i].Clear();
                }
                //}

                ////直接指定单元格进行赋值
                //worksheet.Cells["A2"].Value = "数据2";
                //创建worksheet
                //ExcelWorksheet worksheet1 = package.Workbook.Worksheets.Add("table2");
                ////直接指定行列数进行赋值
                //worksheet1.Cells[1, 1].Value = "名称";
                ////直接指定单元格进行赋值
                //worksheet1.Cells["A2"].Value = "名称";
                package.Save();//保存excel
            }
        }
    }
Пример #13
0
    /// <summary>
    /// 打开文件选框 type文件类型 string是文件路径
    /// </summary>
    /// <param name="type"></param>
    public static void OpenDirectory(string type, Action <string> successCallback, Action failedCallback)
    {
        OpenFileName openFileName = new OpenFileName();

        openFileName.structSize   = Marshal.SizeOf(openFileName);
        openFileName.filter       = "文件(*." + type + ")\0*." + type + "";
        openFileName.file         = new string(new char[256]);
        openFileName.maxFile      = openFileName.file.Length;
        openFileName.fileTitle    = new string(new char[64]);
        openFileName.maxFileTitle = openFileName.fileTitle.Length;
        openFileName.initialDir   = Application.dataPath.Replace('/', '\\');//默认路径
        openFileName.title        = "选择文件";
        openFileName.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;

        if (LocalDialog.GetOpenFileName(openFileName))//点击系统对话框框保存按钮
        {
            if (successCallback != null)
            {
                successCallback.Invoke(openFileName.file);
            }
        }
        else
        {
            if (failedCallback != null)
            {
                failedCallback.Invoke();
            }
        }
    }
Пример #14
0
 private void OnGUI()
 {
     GUILayout.BeginHorizontal();
     md5Path = EditorGUILayout.TextField("ABMD5文件路径", md5Path, GUILayout.Width(350), GUILayout.Height(20));
     if (GUILayout.Button("选择版本ABMD5文件", GUILayout.Width(150), GUILayout.Height(20)))
     {
         m_OpenFileName              = new OpenFileName();
         m_OpenFileName.structSize   = Marshal.SizeOf(m_OpenFileName);
         m_OpenFileName.filter       = "ABMD5文件(*.bytes)\0*.bytes";
         m_OpenFileName.file         = new string(new char[256]);
         m_OpenFileName.maxFile      = m_OpenFileName.file.Length;
         m_OpenFileName.fileTitle    = new string(new char[64]);
         m_OpenFileName.maxFileTitle = m_OpenFileName.fileTitle.Length;
         m_OpenFileName.initialDir   = (Application.dataPath + "/../Version").Replace("/", "\\");//默认路径
         m_OpenFileName.title        = "选择MD5窗口";
         m_OpenFileName.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
         if (LocalDialog.GetSaveFileName(m_OpenFileName))
         {
             Debug.Log(m_OpenFileName.file);
             md5Path = m_OpenFileName.file;
         }
     }
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     hotCount = EditorGUILayout.TextField("ABMD5文件路径", hotCount, GUILayout.Width(350), GUILayout.Height(20));
     GUILayout.EndHorizontal();
     if (GUILayout.Button("开始打热更包", GUILayout.Width(100), GUILayout.Height(20)))
     {
         if (!string.IsNullOrEmpty(md5Path) && md5Path.EndsWith("bytes"))
         {
             BundleEditor.BuildAB(true, md5Path, hotCount);
         }
     }
 }
Пример #15
0
    public static void OpenPhoto()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        ofn.filter = "(*.jpg*.png)\0*.jpg;*.png";

        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;// 默认路径

        ofn.title = "Open Project";

        // ofn.defExt = "jpg";// 显示文件的类型

        ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR

        if (WindowDll.GetOpenFileName(ofn))
        {
            //Debug.Log("Selected file with full path: {0}" + ofn.file);

            ////需要增加压缩处理
            //OnPhotoCameraFileResult(ofn.file);
            OpenFile(ofn.file);
        }
    }
Пример #16
0
    public static bool Open(string title, Action <string> handler, string defExt = "", string filter = "All Files\0*.*\0\0", string initialDir = null)
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize   = Marshal.SizeOf(ofn);
        ofn.filter       = filter;
        ofn.file         = new string(new char[256]);
        ofn.maxFile      = ofn.file.Length;
        ofn.fileTitle    = new string(new char[64]);
        ofn.maxFileTitle = ofn.fileTitle.Length;
        if (initialDir == null)
        {
            initialDir = UnityEngine.Application.dataPath;
        }
        ofn.initialDir = initialDir;
        ofn.title      = title;
        ofn.defExt     = defExt;
        ofn.flags      = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;   //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
        if (OpenFileDialogDLL.GetOpenFileName(ofn))
        {
            handler(ofn.file);
            return(true);
        }
        return(false);
    }
Пример #17
0
    public void GetPather()        // 加载图片
    {
        OpenFileName openFileName = new OpenFileName();

        openFileName.structSize   = Marshal.SizeOf(openFileName);
        openFileName.filter       = "图片文件(*.jpg,*.png,*.bmp)\0*.jpg;*.png;*.bmp";
        openFileName.file         = new string(new char[256]);
        openFileName.maxFile      = openFileName.file.Length;
        openFileName.fileTitle    = new string(new char[64]);
        openFileName.maxFileTitle = openFileName.fileTitle.Length;
        if (texPath == null)
        {
            openFileName.initialDir = Application.streamingAssetsPath.Replace('/', '\\');//默认路径
        }
        else
        {
            openFileName.initialDir = texPath;
        }
        openFileName.title = "选择图片";
        openFileName.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;

        if (LocalDialog.GetSaveFileName(openFileName))
        {
            texPath = openFileName.file;
            Debug.Log(texPath);
            texName = openFileName.fileTitle;
            StartCoroutine(FileStreamLoadTexture(texPath, texName));
        }
    }
Пример #18
0
    public void OpenFileWin()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        ofn.filter = "All Files\0*.*\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;
        string path = Application.streamingAssetsPath;

        path = path.Replace('/', '\\');
        //默认路径
        ofn.initialDir = path;

        ofn.title = "Open Project";

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

        if (WindowDll.GetOpenFileName(ofn))
        {
            Debug.Log("path is " + ofn.file);
            //选择E:\Work\controlTest\Assets\StreamingAssets\x86_64下的dll测试
            string outResult = WindowDll.LoadLibraryTool("inputtest", ofn.file, "testDllMethod111");
            Debug.Log("output is " + outResult);
        }
    }
    bool OpenFilePanel(string filter, string defExt, out string resultPath)
    {
        OpenFileName openChartFileDialog = new OpenFileName();

        openChartFileDialog.structSize = Marshal.SizeOf(openChartFileDialog);
        openChartFileDialog.dlgOwner   = GetActiveWindow();

        openChartFileDialog.filter       = filter;
        openChartFileDialog.file         = new String(new char[256]);
        openChartFileDialog.maxFile      = openChartFileDialog.file.Length;
        openChartFileDialog.fileTitle    = new String(new char[64]);
        openChartFileDialog.maxFileTitle = openChartFileDialog.fileTitle.Length;

        openChartFileDialog.initialDir = "";
        openChartFileDialog.title      = "Open file";
        openChartFileDialog.defExt     = defExt;

        if (GetOpenFileName(openChartFileDialog))
        {
            resultPath = new string(openChartFileDialog.file.ToCharArray());
            return(true);
        }
        else
        {
            CommonDialogBox.ErrorCodes errorCode = CommonDialogBox.GetErrorCode();
            if (errorCode != CommonDialogBox.ErrorCodes.None)
            {
                ChartEditor.Instance.errorManager.QueueErrorMessage("Error occured when bringing up the Open File file explorer. \nError Code: " + errorCode);
            }

            resultPath = string.Empty;
            return(false);
        }
    }
Пример #20
0
        public static string SaveDialog(string title, string path)
        {
            var          extension = Path.GetExtension(path);
            OpenFileName ofn       = new OpenFileName();

            ofn.structSize  = Marshal.SizeOf(ofn);
            ofn.filter      = Filter("All Files", "*.*", extension, "*" + extension);
            ofn.filterIndex = 2;
            var chars = new char[256];
            var it    = Path.GetFileName(path).GetEnumerator();

            for (int i = 0; i < chars.Length && it.MoveNext(); ++i)
            {
                chars[i] = it.Current;
            }
            ofn.file         = new string(chars);
            ofn.maxFile      = ofn.file.Length;
            ofn.fileTitle    = new string(new char[64]);
            ofn.maxFileTitle = ofn.fileTitle.Length;
            ofn.initialDir   = Path.GetDirectoryName(path);
            ofn.title        = title;
            //ofn.defExt = "PNG";
            ofn.flags = 0x00000002 | 0x00000004; // OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
            if (!GetSaveFileName(ofn))
            {
                return(null);
            }

            return(ofn.file);
        }
Пример #21
0
 public static void OutputGuildTimeLine(GuildTimelineData timelineData, string defaultName)
 {
     try
     {
         OpenFileName openFileName = new OpenFileName();
         openFileName.structSize   = Marshal.SizeOf(openFileName);
         openFileName.filter       = "Lua scripts(*.lua)\0*.lua\0";
         openFileName.file         = new string(new char[256]);
         openFileName.maxFile      = openFileName.file.Length;
         openFileName.fileTitle    = new string(new char[64]);
         openFileName.maxFileTitle = openFileName.fileTitle.Length;
         openFileName.initialDir   = Application.dataPath;
         openFileName.title        = "选择保存Lua脚本路径";
         openFileName.defExt       = "lua";
         openFileName.file         = defaultName;
         openFileName.flags        = 530952;
         var flag = DllTest.GetSaveFileName(openFileName);
         var text = openFileName.file.Replace("\\", "/");
         if (flag)
         {
             SaveTimeline(timelineData, text);
         }
     }
     catch (Exception e)
     {
         MainManager.Instance.WindowConfigMessage(e.ToString(), null);
     }
 }
Пример #22
0
        public static string FileDialog(string title, params string[] extensions)
        {
            OpenFileName ofn = new OpenFileName();

            ofn.structSize = Marshal.SizeOf(ofn);

            var filters = new List <string>();

            filters.Add("All Files"); filters.Add("*.*");
            foreach (var ext in extensions)
            {
                filters.Add(ext); filters.Add("*" + ext);
            }
            ofn.filter       = Filter(filters.ToArray());
            ofn.filterIndex  = 2;
            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;
            ofn.title        = title;
            //ofn.defExt = "PNG";
            ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
            if (!GetOpenFileName(ofn))
            {
                return(null);
            }

            return(ofn.file);
        }
Пример #23
0
    void OnGUI()
    {
        if(GUI.Button(new Rect(0,0,67,51),"",open))
        {
            OpenFileName ofn = new OpenFileName();

            ofn.structSize = Marshal.SizeOf(ofn);

            ofn.filter = "JPG Files (*.jpg)\0*.jpg\0All Files (*.*)\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;//默认路径

            ofn.title = "打开文件";

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

            //if (DllTest.GetOpenFileName(ofn))
            //{
            //    StartCoroutine(WaitLoad(ofn.file));//加载图片到panle
            //    Debug.Log("Selected file with full path: {0}" + ofn.file);
                        //}
        }
    }
Пример #24
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        //DrawDefaultInspector();
        //MeshFilter tbg = (MeshFilter) target;
        if (GUILayout.Button("Export"))
        {
            Debug.Log("Save Command");
            OpenFileName ofn = new OpenFileName();
            ofn.structSize   = Marshal.SizeOf(ofn);
            ofn.filter       = "folder name";
            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;          //默认路径
            ofn.title        = "Save Project";
            //OFN_FILEMUSTEXIST|OFN_EXPLORER|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
            ofn.flags = 0x00000008;            // | 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200;//

            //if (DllTest.GetSaveFileName(ofn))
            //{
            //    Debug.Log(ofn.file);
            //}
            string newPrefabPath = EditorUtility.SaveFilePanel("Folder", "", "", "");
            if (newPrefabPath != null)
            {
                SelectMeshList(newPrefabPath + "/");
            }
        }
    }
        public static Task <DialogResult> OpenDialog()
        {
            return(new Task <DialogResult>(() =>
            {
                var ofn = new OpenFileName();
                ofn.lStructSize = Marshal.SizeOf(ofn);
                ofn.lpstrFilter = Filter + "\0\0";
                ofn.Flags = 0x00001000 | 0x00000800 | 0x00000008;//OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR

                var strFile = new char[1024];
                Array.Copy(FileName.ToCharArray(), strFile, FileName.Length);

                ofn.lpstrFile = new string(strFile);
                ofn.nMaxFile = ofn.lpstrFile.Length;
                ofn.lpstrFileTitle = new string(new char[256]);
                ofn.nMaxFileTitle = ofn.lpstrFileTitle.Length;
                ofn.lpstrTitle = Title;
                if (GetOpenFileName(ofn))
                {
                    FileName = GetString(ofn.lpstrFile.ToCharArray());
                    return DialogResult.OK;
                }

                return DialogResult.Cancel;
            }));
        }
Пример #26
0
    public static OpenFileName GetOpenFileInfo()
    {
        OpenFileName info = new OpenFileName();

        info.structSize = Marshal.SizeOf(info);

        info.filter = "Json(.json)|*.json";

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

        info.maxFile = info.file.Length;

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

        info.maxFileTitle = info.fileTitle.Length;

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

        info.title = "Selected File";

        //显示文件的类型
        info.defExt = "Json";//"JPG";

        //注意一下项目不一定要全选 但是0x00000008项不要缺少
        //0x00080000|0x00001000|0x00000800|0x00000200|0x00000008
        //OFN_EXPLORER |OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
        info.flags = 0x00001000 | 0x00000008;



        return(info);
    }
Пример #27
0
    public static void GetFile()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        ofn.filter = "JPG Files\0*.jpg\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;//

        ofn.title = "选择头像";

        ofn.defExt = "JPG";//

        //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
        ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;

        if (DllTest.GetOpenFileName(ofn))
        {
            string path = ofn.file;
            path = path.Replace('\\', '/');
            HeaderManager.Instance.UploadHeader(path);
        }
    }
Пример #28
0
     public static bool GetOpenFileName1([In,  Out]  OpenFileName ofn)   
     
 {
       
             return GetOpenFileName(ofn);   
             
 }
Пример #29
0
    /// <summary>
    /// 加载文件为AudioClip
    /// </summary>
    /// <param name="file"></param>
    /// <returns></returns>
    IEnumerator GetAudioClip(OpenFileName file)
    {
        string path = file.file;

        Debug.print(path);
        audioS.Stop();
        using (var uwr = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.WAV))

        {
            yield return(uwr.SendWebRequest());

            if (uwr.isNetworkError)

            {
                Debug.print("uwrERROR:" + uwr.error);
            }

            else

            {
                audioS.clip = DownloadHandlerAudioClip.GetContent(uwr);
                Audio.ResetHighest();
                audioS.Play();
            }
        }
    }
    public void ThreadSelect()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        //三菱(*.gxw)\0*.gxw\0西门子(*.mwp)\0*.mwp\0All Files\0*.*\0\0
        ofn.filter = "All Files\0*.mp4;*.mpg\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 = objectThread.UnityFullpath;        //默认路径

        ofn.title = "Open Picture";

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


        if (DllComdlg.GetOpenFileName(ofn))
        {
            // StartCoroutine(WaitLoad(ofn.file));//加载图片到panle
            string filename = "file:///" + Utility.StrictLinuxStyle(ofn.file);
            Debug.Log("Selected file with full path========: " + filename);
            ofn.file = filename;

            FileItem item = new FileItem();
            item._fileInfo = new OpenFileNameEx(ofn);
            item._fileType = FileItem.FileType.FileType_Video;
            //FileListControl.Instance ().AddFile (item);

            //file path must convert for url path...
            //VideoPreviewer.Instance().StartPreview  ("file:///C:/Unity3d/dangmu/dangmu/Assets/Dangmu/Textures/WeChat_20180305193437.mp4", PreViewDone);

            /*lock (VideoPreviewer.Instance()) {
             *      //VideoPreviewer.Instance ().StartPreview (filename, PreViewDone);
             * }*/
            lock ( objectThread ) {
                objectThread.BUnityWorkMutex = true;
                objectThread.UnityFullpath   = filename;
            }
            //StartCoroutine ( WaitLoadTexture(ofn.file) );
        }         /*
                   * if (od.ShowDialog() == DialogResult.OK)
                   * {
                   *    Debug.Log(od.FileName);
                   *    lock (obj) {
                   *    }
                   *    this.StartCoroutine(GetTexture("file://" + od.FileName));
                   * }*/
        Thread.CurrentThread.Abort();
    }
Пример #31
0
    public static void OpenFile()
    {
        OpenFileName openFileName = OpenFileManager("OpenFile");

        if (LocalDialog.GetOpenFileName(openFileName))
        {
        }
    }
Пример #32
0
        public ShellOpenFileDialog()
        {
            _ofn = new OpenFileName();
              _ofn.structSize = Marshal.SizeOf(_ofn);
              _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.flags = OFN_ENABLESIZING | OFN_FORCESHOWHIDDEN;
        }
Пример #33
0
        public void OpenFile()
        {
            string path = EditorConfig.Instance.LastOpenFilePath;
            OpenFileName ofn = new OpenFileName("打开文件", path, false);
            if (GetOpenFileName(ofn))
            {
                path = ofn.file;
                EditorConfig.Instance.LastOpenFilePath = path;

                string json = File.ReadAllText(path);
                SceneSetting data = SimpleJson.DeserializeObject<SceneSetting>(json);
                GameEditor.Instance.LoadMap(data, path);
            }

            CloseMenu();
        }
Пример #34
0
    void OnGUI()
    {
        if (isPlay)
        {
            GUI.DrawTexture(new Rect(0, 0, 320, 240), cameraTexture, ScaleMode.ScaleAndCrop);
        }

        if (GUI.Button(new Rect(0, 0, 100, 35), "OpenDialog"))
        {
            OpenFileName ofn = new OpenFileName();

            ofn.structSize = Marshal.SizeOf(ofn);

            ofn.filter = "All Files\0*.*\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;//默认路径

            ofn.title = "Open Project";

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

            if (WindowDll.GetOpenFileName(ofn))
            {
                Debug.Log("Selected file with full path: {0}" + ofn.file);
            }

        }
    }
Пример #35
0
    public static string ShowWindowsDialog()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf( ofn );

        ofn.filter = "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 = "C:\\";
        ofn.title = "Open file";
        ofn.defExt = "";

        LibWrap.GetOpenFileName (ofn);

        Console.WriteLine ("File Selection: "+ofn.file);
        return ofn.file;
    }
	//This method will login the accounts.
	private void LoginGUI ()
	{
		if (showInventory) {
			GUI.Box (new Rect (550, 160, 300, 400), "Send email");
			
			// From (email)
			GUI.Label (new Rect (590, 180, 220, 23), "From (email):");
			fromEmail = GUI.TextField (new Rect (590, 200, 220, 23), fromEmail);
			// From (name)
			GUI.Label (new Rect (590, 220, 220, 23), "From (name):");
			fromName = GUI.TextField (new Rect (590, 240, 220, 23), fromName);
			// From (password)
			GUI.Label (new Rect (590, 260, 220, 23), "Paswword (sender):");
			fromPassword = GUI.PasswordField (new Rect (590, 280, 220, 23), fromPassword, "*" [0]);
			// Subject
			GUI.Label (new Rect (590, 300, 220, 23), "Subject :");
			fromSubject = GUI.TextField (new Rect (590, 320, 220, 23), fromSubject);
			// Message
			GUI.Label (new Rect (590, 340, 220, 23), "Message :");
			scrollPosition = GUI.BeginScrollView (new Rect (590, 360, 220, 200), scrollPosition, new Rect (0, 0, 200, 200));
			fromBody = GUI.TextArea (new Rect (0, 00, 220, 70), fromBody);
			GUI.EndScrollView ();


			if(GUIButton_scripts.clientType == "worker"){
			
				// Attachement
				GUI.Label (new Rect (590, 430, 220, 23), "Attache file :");
				fromAttachement = GUI.TextField (new Rect (640, 450, 170, 23), fromAttachement);

				if (GUI.Button (new Rect (590, 450, 45, 23), "Open")) {
					OpenFileName ofn = new OpenFileName ();
					
					ofn.structSize = Marshal.SizeOf (ofn);
					
					ofn.filter = "All Files\0*.*\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;
					
					ofn.title = "Attache file to your email";
					
					ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
					//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
					
					if (DllOpen.GetOpenFileName (ofn)) {
						fromAttachement = ofn.file;
					}
				}
			}

			// To (email)
			GUI.Label (new Rect (590, 470, 220, 23), "To (email):");
			toEmail = GUI.TextField (new Rect (590, 490, 220, 23), toEmail);
			
			if (GUI.Button (new Rect (590, 520, 120, 25), "Send")) {
				sereverIP += ConnectionHandler_scripts.ip+":80";

				if(GUIButton_scripts.clientType == "worker"){
					WebClient client = new WebClient();
					client.UploadFile(sereverIP+"/sendMail/upload.php", "POST", fromAttachement);
				}
				
				string filename = Path.GetFileName(fromAttachement);
				
				string loginURL = sereverIP+"/sendMail/mail.php?from="+fromName+"&fromName="+fromEmail+"&password="******"&to="
					+toEmail+"&subject="+fromSubject+"&body="+fromBody+"&file="+filename;
				Debug.Log(loginURL);
				WWW w = new WWW(loginURL);
				StartCoroutine(login(w));
			}
		}
		
	}//End Login GUI
Пример #37
0
        public void SaveFileAs()
        {
            string path = EditorConfig.Instance.LastSaveFilePath;
            OpenFileName ofn = new OpenFileName("保存文件", path, true);
            if (GetSaveFileName(ofn))
            {
                path = ofn.file;
                EditorConfig.Instance.LastSaveFilePath = path;
                DoSaveFile(path);
            }

            CloseMenu();
        }
Пример #38
0
        private void MenuItemOnClick_SaveAs(object sender, RoutedEventArgs e)
        {
            if (viewCtrl.SelectedItem != null)
            {
                if ((viewCtrl.SelectedItem as TabItem).Tag is GraphicalCMakeProject)
                {
                    OpenFileName ofn = new OpenFileName();
                    ofn.structSize = Marshal.SizeOf(ofn);
                    ofn.filter = "XML file\0*.xml\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 = "C:\\";
                    ofn.title = "Save as ...";
                    ofn.defExt = "xml";
                    if (GetSaveFileName(ofn))
                        ((viewCtrl.SelectedItem as TabItem).Tag as GraphicalCMakeProject).SaveAs(ofn.file);
                }
            }
        }
Пример #39
0
 public static extern bool GetOpenFileNameW(ref OpenFileName openFileNameInfo);
Пример #40
0
    public void OpenWrite(string data)
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = System.Runtime.InteropServices.Marshal.SizeOf(ofn);

        ofn.filter = "All Files\0*.*\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;//默认路径

        ofn.title = "Open Project";

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

        if (WindowDll.GetOpenFileName(ofn))
        {
            Debug.Log(data);
            SkillWindow.XmlPath = ofn.file;
            FileStream fs = new FileStream(SkillWindow.XmlPath, FileMode.Create, FileAccess.Write);
            fs.SetLength(0);
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            sw.Write(data);
            sw.Close();
            fs.Close();

        }
    }
Пример #41
0
    public void OpenRead()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = System.Runtime.InteropServices.Marshal.SizeOf(ofn);

        ofn.filter = "All Files\0*.*\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;//默认路径

        ofn.title = "Open Project";

        ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR

        if (WindowDll.GetOpenFileName(ofn))
        {
            Datas.Clear();
            SkillWindow.XmlPath = ofn.file;
            XmlDocument xml = new XmlDocument();
            xml.Load(SkillWindow.XmlPath);
            XmlNodeList childs = xml.SelectNodes("/skills/ui/skill");
            foreach (XmlNode child in childs)
            {
                SkillData tk = DeserializeXml.Deserialize(child, xml.SelectSingleNode(@"/skills/datas/skill[@id='" + child.Attributes["id"].Value + "']"));
                Datas.Add(tk);
            }
            ClearGraph();
        }
    }