贵州住房和城乡建设厅旧网站,佛山网站专家,展架设计在哪个网站做,短视频seo排名加盟Luban 文档及链接项目目录UnityEditor 导表工具 文档及链接
官方文档
最新版本
项目目录
接入的方法有很多#xff0c;我这里随便找了一种
https://gitee.com/focus-creative-games/luban_examples.git如上图#xff0c;git拉去后#xff0c;只保留圈起来的2个文件夹。… Luban 文档及链接项目目录UnityEditor 导表工具 文档及链接
官方文档
最新版本
项目目录
接入的方法有很多我这里随便找了一种
https://gitee.com/focus-creative-games/luban_examples.git如上图git拉去后只保留圈起来的2个文件夹。基础使用已经够了
每个项目工程目录不尽相同这里及以下根据我自己的项目目录配置 在Unity平级目录创建一个文件夹用来存放导表工具Luban 将上面Git保留的2个文件夹放入这个文件夹下如上图 这个路径下存放的是配置表将配表填入_tables_.xlsx中用以生成表数据及代码 这个是生成工具需要用文档打开修改为自己路径
set WORKSPACE..
set LUBAN_DLL%WORKSPACE%\Tools\Luban\Luban.dll
set CONF_ROOT.dotnet %LUBAN_DLL% ^-t client ^-c cs-simple-json ^-c cs-bin ^-d json ^-d bin ^--conf %CONF_ROOT%\luban.conf ^-x cs-simple-json.outputCodeDir..\Code\Json ^-x cs-bin.outputCodeDir..\..\ClientFrame\Assets\Game\Scripts\DataTable ^-x json.outputDataDir..\..\ClientFrame\Assets\DataTable\Json ^-x bin.outputDataDir..\..\ClientFrame\Assets\Res\Tablepause这里同时导出了二进制和json,项目中用的是二进制Json用于自己查表方便。可根据自己需求保留二进制和json outputCodeDir是导出代码路径 outputDataDir是导出数据路径 可根据自己需求修改路径。
例如只保留二进制
set WORKSPACE..
set LUBAN_DLL%WORKSPACE%\Tools\Luban\Luban.dll
set CONF_ROOT.dotnet %LUBAN_DLL% ^-t client ^-c cs-bin ^-d bin ^--conf %CONF_ROOT%\luban.conf ^-x cs-bin.outputCodeDir..\..\ClientFrame\Assets\Game\Scripts\DataTable ^-x bin.outputDataDir..\..\ClientFrame\Assets\Res\TablepauseUnityEditor 导表工具
每次导表需要到项目找到对应文件夹执行bat很麻烦。 在UnityEditor 加个工具直接执行bat导表 using System.Diagnostics;
using System.IO;
using UnityEngine;
using UnityEditor;public class LubanExpand
{[MenuItem(Luban/Export Excel)]public static void ExecuteBat(){// 获取上一级目录var parentPath Path.GetDirectoryName(Path.GetDirectoryName(Application.dataPath));// 确定 .bat 文件的绝对路径var batFilePath Path.Combine(parentPath, Luban/DataTables/gen.bat).Replace(\\, / );// 获取.bat文件所在目录var batDirectory Path.GetDirectoryName(batFilePath);if (!File.Exists(batFilePath)){UnityEngine.Debug.LogError($Bat file not found: {batFilePath});return;}try{var processInfo new ProcessStartInfo{FileName batFilePath,UseShellExecute false, // 不使用系统ShellRedirectStandardOutput true, // 重定向输出RedirectStandardError true, // 重定向错误CreateNoWindow false, // 不创建新窗口WorkingDirectory batDirectory // 关键点工作目录设为.bat所在文件夹};var process new Process { StartInfo processInfo };process.Start();// 读取输出防止进程阻塞var output process.StandardOutput.ReadToEnd();var error process.StandardError.ReadToEnd();process.WaitForExit();AssetDatabase.Refresh();if (!string.IsNullOrEmpty(output))UnityEngine.Debug.Log($Bat Output:\n{output});if (!string.IsNullOrEmpty(error))UnityEngine.Debug.LogError($Bat Error:\n{error});UnityEngine.Debug.Log(Bat executed successfully!);}catch (System.Exception e){UnityEngine.Debug.LogError($Failed to execute bat: {e.Message});}}
}
坑点:上面代码中 WorkingDirectory 是指定工作目录。如果不设置工作目录会默认是Unity项目的Assets平级目录gen.bat 里的WORKSPACE 生效错误无法导出