700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Lua之Lua源文件批量转换为luac字节码文件

Lua之Lua源文件批量转换为luac字节码文件

时间:2021-12-04 15:20:21

相关推荐

Lua之Lua源文件批量转换为luac字节码文件

准备的工具:luac.exeCSDN/mp_download/manage/download/UpDetailed

Unity版:

using System;using System.Collections;using System.Collections.Generic;using System.IO;using UnityEditor;using UnityEngine;public static class Batch_LuaToLuac{[UnityEditor.MenuItem("Tools/LuaToLuac")]static void ToLuac(){//准备进程信息string luacExe = "luac53.exe"; //luac.exe工具文件名string luacExe_Dir = @"D:\workspace\Test\T4\PureProject_Develop\Development\Tools\Lua"; //luac.exe工具路径string luacExe_fullpath = bine(luacExe_Dir, luacExe); //luac.exe工具完整路径var processStartInfo = new System.Diagnostics.ProcessStartInfo();processStartInfo.FileName = luacExe_fullpath;processStartInfo.UseShellExecute = true;processStartInfo.ErrorDialog = true;processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;void DoExe(string srcFile, string outFile){//执行转换进程try{string args = string.Format("-o {0} {1}", outFile, srcFile);processStartInfo.Arguments = args;var process = System.Diagnostics.Process.Start(processStartInfo);process.WaitForExit();}catch (Exception ex){Debug.LogError(ex.ToString());}}//lua源文件路径var luaFileDir = Application.dataPath + "/LuaSource";//生成的luac文件路径var outPutDir = bine(luaFileDir, "luac");if (Directory.Exists(outPutDir)) Directory.Delete(outPutDir, true);Directory.CreateDirectory(outPutDir);var files = Directory.GetFiles(luaFileDir, "*.lua", SearchOption.TopDirectoryOnly);foreach (var file in files){if (file.Contains(".meta")) { continue; }var outFile = bine(outPutDir, Path.GetFileNameWithoutExtension(file) + ".luac");DoExe(file, outFile);}AssetDatabase.Refresh();}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。