Example #1
0
    /// <summary>
    /// 打开文件
    /// </summary>
    /// <returns></returns>
    public static string OpenFile()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize   = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter       = "txt (*.txt)";
        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; // default path
        pth.title        = "打开项目";
        pth.defExt       = "txt";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;//选择的文件路径;
            Debug.Log(filepath);
            return(filepath);
        }
        else
        {
            return("");
        }
    }
Example #2
0
    public string OpenProject()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize   = Marshal.SizeOf(pth);
        pth.filter       = "exe";
        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        = "打开项目";
        pth.defExt       = "dat";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file; //选择的文件路径;
            UnityEngine.Debug.Log(filepath);
            return(pth.file);
        }
        else
        {
            return(null);
        }
    }
Example #3
0
    void OnClickFileBtn()
    {
        OpenFileDlg param = new OpenFileDlg();

        param.structSize   = System.Runtime.InteropServices.Marshal.SizeOf(param);
        param.filter       = "png | *.png;*.jpg;";
        param.file         = new string(new char[256]);
        param.maxFile      = param.file.Length;
        param.fileTitle    = new string(new char[64]);
        param.maxFileTitle = param.fileTitle.Length;
        param.initialDir   = Application.dataPath; // default path
        param.title        = "标题";
        param.defExt       = "png";
        param.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;

        if (OpenFileDialog.GetOpenFileName(param))
        {
            Debug.Log(param.file);

            if (coroutine == null)
            {
                coroutine = StartCoroutine(ReadTexture(param.file));
            }
        }
    }
    public static void CustomSubMenu1()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter     = "支持的模型文件(*.3DXML)\0*.3DXML";

        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   = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); // default path
        pth.title        = "导入模型";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;

        if (!OpenFileDialog.GetOpenFileName(pth))
        {
            return;
        }

        string filepath = pth.file; //选择的文件路径;
                                    //Debug.Log(filepath);
        XmlModel x = new XmlModel(filepath);

        DestroyImmediate(GameObject.Find("ModelGenerator"));
        x.Render(new GameObject("ModelGenerator"));



        //打出一行字:模板生成在。。。.xml,请手动设置动画参数,或使用第二个选项自动设置参数。
    }
    static public string OpenFile()
    {
        string filepath = "";

        #if UNITY_EDITOR
        filepath = EditorUtility.OpenFilePanel("Open File", _lastDir, "yo");
        _lastDir = filepath;
        #else
        OpenFileDlg pth = new OpenFileDlg();
        pth.structSize   = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter       = "yo (*.yo)";
        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   = _lastDir;    // default path
        pth.title        = "打开文件";
        pth.defExt       = "yo";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            filepath = pth.file;    //选择的文件路径;
            _lastDir = filepath;
        }
        #endif
        return(filepath);
    }
Example #6
0
    public static string AddGame()
    {
        OpenFileDlg pth      = new OpenFileDlg();
        string      filepath = null;

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

        //pth.filter = "exe (*.exe)";
        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   = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); // default path
        pth.title        = "请选择游戏";
        pth.defExt       = "exe";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        //0x00080000   是否使用新版文件选择窗口
        //0x00000200   是否可以多选文件
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            filepath = pth.file;//选择的文件路径;
        }
        Debug.Log(filepath);
        return(filepath);
    }
    public static void CustomSubMenu3()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter     = "动画模板文件(*.XML)\0*.XML";

        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   = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); // default path
        pth.title        = "载入模板";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;

        if (!OpenFileDialog.GetOpenFileName(pth))
        {
            return;
        }

        string filepath = pth.file;//选择的文件路径;


        string[] strlis = File.ReadAllLines(filepath, Encoding.UTF8);
        File.WriteAllLines("XmlAnimation\\Animation.xml", strlis, Encoding.UTF8);
        Debug.Log("成功载入动画指令序列!");
    }
Example #8
0
    public static string OpenFile(string title, string defaultPath, string filter)
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize   = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter       = string.Format("{0}(*.{1})\0*.{2}", filter, filter, filter);
        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   = defaultPath; // default path
        pth.title        = title;
        pth.defExt       = filter;
        //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
        pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            Debug.Log(pth.file);
            return(pth.file);//选择的文件路径;
        }
        else
        {
            return(null);
        }
    }
    void UploadFile()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        //pth.filter = "all (*.*)";
        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; // default path
        //pth.title = "Upload data";
        //pth.defExt = "txt";
        pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
                //0x00080000   是否使用新版文件选择窗口
                //0x00000200   是否可以多选文件
                if(OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;

            paramSetting.ParseFile(filepath);
            //string newfile = Application.streamingAssetsPath + "/" + pth.fileTitle;

            //if (!Directory.Exists(Application.streamingAssetsPath)) {
            //    Directory.CreateDirectory(Application.streamingAssetsPath);
            //}
            //File.WriteAllText(newfile, File.ReadAllText(filepath));
        }
    }
Example #10
0
    public void OpenFile()
    {
        OpenFileBrowse pth = new OpenFileBrowse();

        pth.structSize = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        //pth.filter = "txt files(.txt)|.txt";
        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; // default path
        pth.title        = "打开项目";
        pth.defExt       = "txt";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        //0x00080000   是否使用新版文件选择窗口
        //0x00000200   是否可以多选文件
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;//选择的文件路径;
            MenuButton.path = filepath;

            string text = File.ReadAllText(@filepath);

            inputText.text = text;
        }
    }
Example #11
0
 /// <summary>
 /// 打开窗口
 /// </summary>
 /// <returns></returns> 和该文件相关的数据
 public OpenDialogData OpenFileDlg()
 {
     if (OpenFileDialog.GetOpenFileName(CustomOpenData))
     {
         return(CustomOpenData);
     }
     return(null);
 }
Example #12
0
    public void Btn_Open_Click()
    {
        OpenFileDlg pth = new OpenFileDlg();

        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.Replace("/", "\\") + "\\Resources";
        pth.title        = "Open Project";
        pth.defExt       = "dat";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;
            Debug.Log(filepath);
            StreamReader sr = new StreamReader(filepath);
            sr.ReadLine();
            string        input = sr.ReadToEnd();
            string[]      s     = input.Split('\r');
            StringBuilder sb2   = new StringBuilder();
            for (int i = 0; i < s.Count(); i++)
            {
                string[] ss = s[i].Split(',');
                if (ss.Count() < 3)
                {
                    break;
                }
                int j = 0;
                foreach (GameObject l in lineList)
                {
                    if (j == 0)
                    {
                        Debug.Log(System.Convert.ToInt32(ss[0]));
                        m_DataDiagram.InputPoint(l, new Vector2(1, (float)(System.Convert.ToInt32(ss[0].ToString()) / 10.0)));
                        Debug.Log(System.Convert.ToInt32(ss[0]));
                    }
                    else if (j == 1)
                    {
                        Debug.Log(System.Convert.ToInt32(ss[1]));
                        m_DataDiagram.InputPoint(l, new Vector2(1, (float)(System.Convert.ToInt32(ss[1].ToString()) / 10.0)));
                        Debug.Log(System.Convert.ToInt32(ss[1]));
                    }
                    else
                    {
                        Debug.Log(System.Convert.ToInt32(ss[2]));
                        m_DataDiagram.InputPoint(l, new Vector2(1, (float)(System.Convert.ToInt32(ss[2].ToString()) / 10.0)));
                        Debug.Log(System.Convert.ToInt32(ss[2]));
                    }
                    j++;
                }
            }
        }
    }
Example #13
0
    /// <summary>
    /// 打开项目
    /// </summary>
    public void OpenProject(FileType fileType, System.Action <string> action)
    {
        OpenQueueCall = action;
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize = Marshal.SizeOf(pth);
        switch (fileType)
        {
        case FileType.All:
            pth.filter = "All files (*.*)\0*.*";
            break;

        case FileType.png:
            pth.filter = "All files (*.png)\0*.png";
            break;

        case FileType.jpg:
            pth.filter = "All files (*.jpg)\0*.jpg";
            break;

        case FileType.txt:
            pth.filter = "All files (*.txt)\0*.txt";
            break;

        case FileType.json:
            pth.filter = "All files (*.json)\0*.json";
            break;

        default:
            break;
        }
        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        = "打开项目";
        pth.defExt       = "dat";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file; //选择的文件路径;
            Debug.Log(filepath);
            OpenQueueCall?.Invoke(filepath);
            OpenQueueCall = null;
        }
    }
Example #14
0
    public static string GetOpenFilePath()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize   = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter       = "REC (*.rec)\0*.rec\0\0";
        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;
        pth.title        = "选择要导入的存档";
        pth.defExt       = "rec";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;
            return(filepath);
        }
        return(null);
    }
    public void OpenProject()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize   = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter       = "十六进制文件(*.hex)\0*.hex\0\0";
        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 + @"/GameData/Rooms";
        pth.title        = "打开hex项目";
        pth.defExt       = "hex";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;            //选择的文件路径;
            Debug.Log(filepath);
            string s = "";
            MainManager.instance.hexFile = HexFileIO.ReadHexFile(filepath, out s);
            ShowHex();
        }
    }
Example #16
0
    /// <summary>
    /// 打开项目
    /// </summary>
    /// <returns>项目路径</returns>
    public string OpenProject(Action <string> _event)
    {
        OpenFileDlg _openFileDlg = new OpenFileDlg();

        _openFileDlg.structSize   = Marshal.SizeOf(_openFileDlg);
        _openFileDlg.filter       = filter;
        _openFileDlg.file         = new string(new char[256]);
        _openFileDlg.maxFile      = _openFileDlg.file.Length;
        _openFileDlg.fileTitle    = new string(new char[64]);
        _openFileDlg.maxFileTitle = _openFileDlg.fileTitle.Length;
        _openFileDlg.initialDir   = defaultPath;
        _openFileDlg.title        = windowTitle;
        _openFileDlg.defExt       = defaultExt;
        _openFileDlg.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;

        if (OpenFileDialog.GetOpenFileName(_openFileDlg))
        {
            string _filepath = _openFileDlg.file;//选择的文件路径;
            _event(_filepath);
            return(_filepath);
        }
        return(null);
    }
Example #17
0
    private void Load()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize   = Marshal.SizeOf(pth);
        pth.filter       = "bytes (*.bytes)";
        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 + "/HotUpdateRes/Story";        // default path
        pth.title        = "打开story文件";
        pth.defExt       = "bytes";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;            //选择的文件路径;
            ClearAllNode();
            path = pth.file;
            StoryNode sn = BinaryUtil.FileToObject(filepath) as StoryNode;
            AddNodeRecursive(sn);
        }
    }
Example #18
0
    public void OpenProject()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize   = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter       = "txt (*.txt)";
        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; // default path
        pth.title        = "打开项目";
        pth.defExt       = "txt";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
                //0x00080000   是否使用新版文件选择窗口
                //0x00000200   是否可以多选文件
                if(OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;//选择的文件路径;

            Debug.Log(filepath);
        }
    }
Example #19
0
    /// <summary>
    /// 打开模型文件并导入
    /// </summary>
    public static bool OpenFile()
    {
        OpenFileDlg pth = new OpenFileDlg();

        pth.structSize   = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        pth.filter       = "OBJ (*.obj)\0*.obj\0\0";
        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;
        pth.initialDir = @"C:\Users\91812\Desktop\ForImportModel";
        pth.title      = "选择要导入的模型";
        pth.defExt     = "obj";
        pth.flags      = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;
            if (!Directory.Exists(Path.Combine(Application.persistentDataPath, "objects")))
            {
                Directory.CreateDirectory(Path.Combine(Application.persistentDataPath, "objects"));
            }
            var fileName = Guid.NewGuid().ToString() + ".obj";
            File.Copy(filepath, Path.Combine(Application.persistentDataPath, "objects", fileName), true);
            GameManager.Instance.objectsModels.Insert(0, new ObjectsModel()
            {
                id            = 0,
                Name          = Path.GetFileNameWithoutExtension(filepath),
                DetailMessage = "导入的3D物体",
                Integrated    = false,
                PreviewImage  = $"{Application.streamingAssetsPath}/PreviewImages/cubic.png",
                ResourcePath  = Path.Combine(Application.persistentDataPath, "objects", fileName)
            });
            return(true);
        }
        return(false);
    }