Exemple #1
0
        // 打开资源管理器,获取文件地址(输入或选择)
        // 返回空表明直接关闭了窗口
        public static string GetFilePath(string fileName = "New File", string tip = "Asset文件(*.asset)",
                                         string suffix   = ".asset")
        {
            var ofn = new OpenFileName(fileName);

            ofn.filter = tip + "\0*" + suffix;
            bool success = GetSaveFileName(ofn);

            // 直接关闭窗口则返回null
            if (!success)
            {
                return(null);
            }
            int len = Tool_PathSetting.AssetPath.Length;
            // 去除Assets之前的路径
            string path = "Assets" + ofn.file.Substring(len);

            // 检查是否以suffix结尾
            if (!path.EndsWith(suffix))
            {
                path += suffix;
            }

            return(path);
        }
Exemple #2
0
 public static extern bool GetSaveFileName([In, Out] OpenFileName ofn);