Unity学习笔记——Luban工具的使用

下载地址

luban: 你的最佳游戏配置解决方案 {excel, csv, xls, xlsx, json, bson, xml, yaml, lua, unity scriptableobject} => {json, bson, xml, lua, yaml, protobuf(pb), msgpack, flatbuffers, erlang, custom template}

教程地址

强力配置工具luban使用教程【01】_哔哩哔哩_bilibili 

使用流程

第一步:

首先是下载后文件夹:

 DesignerConfigs和MiniTemplate都是可以解析Excle的配置表

流程样例在Projects中我们找到Csharp_Unity_json文件夹中

该文件复制到我们的工程中便于后面加载生成的配置表

第二步:

 在Assets同级目录下新建Luban文件夹,复制这两个文件夹到我们的目录中 

将MiniTemplate文件改名

 

新建  .bat文件

set WORKSPACE=..

set GEN_CLIENT=%WORKSPACE%\Luban\Tools\Luban.ClientServer\Luban.ClientServer.exe
set CONF_ROOT=%WORKSPACE%\Luban\Config

%GEN_CLIENT% -j cfg --^
 -d %CONF_ROOT%\Defines\__root__.xml ^
 --input_data_dir %CONF_ROOT%\Datas ^
 --output_code_dir %WORKSPACE%/Assets/Gen ^
 --output_data_dir ..\Assets\json ^
 --gen_types code_cs_unity_json,data_json ^
 -s all 

pause

运行即可

第三步:加载

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using cfg;
using cfg.item;
using SimpleJSON;
using System.IO;
public class CTest : MonoBehaviour
{
	// Start is called before the first frame update
	void Start()
	{
		Tables tables = new Tables(LoadJson);
		Item item = tables.TbItem.Get(10000);
		print(item.Id);
	}
	JSONNode LoadJson(string name)
	{
		return JSON.Parse(File.ReadAllText(Application.dataPath + "/json/" + name + ".json"));
	}
}

猜你喜欢

转载自blog.csdn.net/qq_55042292/article/details/125665772