Esempio n. 1
0
    public static void MenuCopyExport2StreamingAssets()
    {
        /// 删除资源
        if (System.IO.Directory.Exists(TO_PATH))
        {
            System.IO.Directory.Delete(TO_PATH, true);
        }
        if (System.IO.File.Exists(TO_PATH + "../assetsbundle.meta"))
        {
            System.IO.File.Delete(TO_PATH + "../assetsbundle.meta");
        }

        /// 搜索资源
        List <string> paths = new List <string>();

        EditorSearchFile.SearchPath(FROM_PATH, paths, ".ab");
        for (int index = 0; index < paths.Count; index++)
        {
            string path = EditorSearchFile.FilePath(paths[index]);
            path = TO_PATH + path.Substring(path.LastIndexOf("/assetsbundle/") + "/assetsbundle/".Length);
            string name = EditorSearchFile.FileName(paths[index]);
            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }
            System.IO.File.Copy(paths[index], path + "/" + name + paths[index].Substring(paths[index].LastIndexOf(".")));
        }
        /// AB 资源赋值
        if (System.IO.File.Exists(FROM_PATH + "assetsbundle"))
        {
            System.IO.File.Copy(FROM_PATH + "assetsbundle", TO_PATH + "assetsbundle");
        }

        UnityEditor.AssetDatabase.Refresh();
        UnityEditor.AssetDatabase.SaveAssets();
        /// 刷新
    }
Esempio n. 2
0
    static void MenuInfoExportClass()
    {
        List <string> unexport   = new List <string>();
        string        pathCsv    = Application.dataPath + "/../Config/Info";
        string        exportFile = Application.dataPath + "/Ling-Script/Util/Info/UtilInfoReaderType.cs";
        List <string> files      = new List <string>();

        EditorSearchFile.SearchPath(pathCsv, files, ".info");
        string text_class = "" +
                            "using UnityEngine;\n" +
                            "using System.Collections;\n" +
                            "using System.Collections.Generic;\n" +
                            "namespace Info\n{\n" +
                            "\tpublic class InfoInfo\n" +
                            "\t{\n" +
                            "\t\tpublic static readonly string[] CLASS_NAME = { {REPACE-0} };\n" +
                            "\t\tpublic static readonly System.Type[] CLASS_TYPE = { {REPACE-1} };\n" +
                            "\t}\n";
        string text_class_name = "";
        string text_class_type = "";

        /// 遍历csv文件
        for (int index = 0; index < files.Count; index++)
        {
            string fileName = EditorSearchFile.FileName(files[index]);

            if (unexport.IndexOf(fileName) != -1)
            {
                continue;
            }

            text_class_name += (string.IsNullOrEmpty(text_class_name) ? "\"" : ", \"") + fileName + "\"";
            text_class_type += (string.IsNullOrEmpty(text_class_type) ? "typeof(Info." : ", typeof(Info.") + fileName + ")";

            /// 检测类中变量是否存在
            string[] lines = System.IO.File.ReadAllLines(files[index]);
            text_class += "\tpublic class " + fileName + " : System.Object\n";
            text_class += "\t{\n";
            for (int i = 0; i < lines.Length; i++)
            {
                if (string.IsNullOrEmpty(lines[i]))
                {
                    continue;
                }
                string[] splits = lines[i].Split('=');
                /// 数据 不够 注释补充
                if (splits.Length <= 1)
                {
                    text_class += "\t\t/// " + lines[i] + "\n";
                    continue;
                }
                splits[0] = splits[0].Trim();
                splits[1] = splits[1].Trim();
                /// 属性
                if (splits[0].IndexOf(" ") == -1)
                {
                    text_class += "\t\tpublic string " + splits[0] + ";\n";
                }
                else
                {
                    text_class += "\t\tpublic " + splits[0] + ";\n";
                }
            }
            text_class += "\t}\n";
        }
        text_class += "}\n";

        text_class = text_class.Replace("{REPACE-0}", text_class_name);
        text_class = text_class.Replace("{REPACE-1}", text_class_type);
        System.IO.File.WriteAllText(exportFile, text_class, new System.Text.UTF8Encoding(false));
    }
Esempio n. 3
0
    static void MenuCsvExportClass()
    {
        List <string> unexport   = new List <string>();
        string        pathCsv    = Application.dataPath + "/../Config/Csv";
        string        exportFile = Application.dataPath + "/Ling-Script/Util/Csv/UtilCsvReaderType.cs";
        List <string> fileCsv    = new List <string>();

        EditorSearchFile.SearchPath(pathCsv, fileCsv, ".csv");
        string text_class = "" +
                            "using UnityEngine;\n" +
                            "using System.Collections;\n" +
                            "using System.Collections.Generic;\n" +
                            "namespace CSV\n{\n" +
                            "\tpublic class CSVInfo\n" +
                            "\t{\n" +
                            "\t\tpublic static readonly string[] CLASS_NAME = { {REPACE-0} };\n" +
                            "\t\tpublic static readonly System.Type[] CLASS_TYPE = { {REPACE-1} };\n" +
                            "\t}\n";

        string text_class_name = "";
        string text_class_type = "";

        /// 遍历csv文件
        for (int index = 0; index < fileCsv.Count; index++)
        {
            string fileName = EditorSearchFile.FileName(fileCsv[index]);

            if (unexport.IndexOf(fileName) != -1)
            {
                continue;
            }

            text_class_name += (string.IsNullOrEmpty(text_class_name) ? "\"" : ", \"") + fileName + "\"";
            text_class_type += (string.IsNullOrEmpty(text_class_type) ? "typeof(CSV." : ", typeof(CSV.") + fileName + ")";
            char[] split_char = null;
            switch (fileName)
            {
            case "Dictionary":
            case "DictionaryStatic":
            case "DictionaryLibrary":
                split_char = new char[] { '\t' };
                break;

            default:
                split_char = new char[] { ',' };
                break;
            }
            /// 检测类中变量是否存在
            string[] data  = System.IO.File.ReadAllLines(fileCsv[index]);
            string[] title = data[0].Split(split_char);
            string[] type  = data[1].Split(split_char);
            string[] info  = data[2].Split(split_char);
            for (int i = 0; i < title.Length; i++)
            {
                if (string.IsNullOrEmpty(title[i]))
                {
                    continue;
                }
            }
            text_class += "\tpublic class " + fileName + " : System.Object\n";
            text_class += "\t{\n";
            for (int i = 0; i < title.Length; i++)
            {
                if (string.IsNullOrEmpty(title[i]))
                {
                    continue;
                }
                text_class += "\t\t/// " + (info.Length > i ? info[i] : "") + "\n";
                text_class += "\t\tpublic " + (type.Length > i && !string.IsNullOrEmpty(type[i]) ? type[i] : "string").Replace(" ", "") + " " + title[i] + ";\n";
            }
            text_class += "\t}\n";
        }
        text_class += "}\n";

        text_class = text_class.Replace("{REPACE-0}", text_class_name);
        text_class = text_class.Replace("{REPACE-1}", text_class_type);
        System.IO.File.WriteAllText(exportFile, text_class, new System.Text.UTF8Encoding(false));
    }