Beispiel #1
0
    public static void GenerateSublimeCompletion()
    {
        if (!beAutoGen && EditorApplication.isCompiling)
        {
            EditorUtility.DisplayDialog("警告", "请等待编辑器完成编译再执行此功能", "确定");
            return;
        }

        if (!File.Exists(CustomSettings.saveDir))
        {
            Directory.CreateDirectory(CustomSettings.saveDir);
        }


        ToLuaExport.autocomp.Clear();

        allTypes.Clear();
        BindType[] typeList = CustomSettings.customTypeList;

        BindType[] list = GenBindTypes(typeList);
        ToLuaExport.allTypes.AddRange(baseType);

        for (int i = 0; i < list.Length; i++)
        {
            ToLuaExport.allTypes.Add(list[i].type);
        }

        for (int i = 0; i < list.Length; i++)
        {
            ToLuaExport.Clear();
            ToLuaExport.className     = list[i].name;
            ToLuaExport.type          = list[i].type;
            ToLuaExport.isStaticClass = list[i].IsStatic;
            ToLuaExport.baseType      = list[i].baseType;
            ToLuaExport.wrapClassName = list[i].wrapName;
            ToLuaExport.libClassName  = list[i].libName;
            ToLuaExport.extendList    = list[i].extendList;
            ToLuaExport.GenerateComp(CustomSettings.saveDir);
        }


        string file = "./../../SublimeTolua/quickxlib/tolua.sublime-completions";

        using (StreamWriter textWriter = new StreamWriter(file, false, Encoding.UTF8))
        {
            textWriter.Write("{\n\"scope\": \"source.lua\",\n\"completions\":\n[");
            textWriter.Write(ToLuaExport.autocomp.ToString());

            textWriter.Write("]\n}\n");

            textWriter.Flush();
            textWriter.Close();
        }


        Debug.Log("Generate sublime completion files over");
        ToLuaExport.allTypes.Clear();
        allTypes.Clear();



        AssetDatabase.Refresh();
    }