1.打表工具:

使用打表工具生成数据和代码:

数据保存路径:\unity\Assets\Resources\data

代码保存路径:\unity\Assets\Script\Data

Excel源文件路径:\excel

2.Protobuf

与服务器通信的数据都是通过Protobuf进行序列化和反序列化,生成协议的批处理命令在:\proto\protoClient.bat

生成的协议代码在:\unity\Assets\Script\Network\ProtoMsg

3.Json

场景数据使用json文件配置,解析逻辑使用第三方类库LitJson,源码在:\unity\Assets\Plugins\LitJson.先从Resource目录下加载为字符串,然后解析:

  using (var asset = ServiceCenter.GetService<IAssetManager>().Load("config/terrain/" + mapId + ".json", AssetType.Text))
            {
                MapConfig.Clear();
                MapConfig.Parse(asset.Cast<string>());
            }

4.Xml

项目中食物,玩家球等通过xml配置,采用.net原生类解析,也是先从Resource目录加载成字符创解析.

private void InitFood(int id)
        {
            using (var asset = ServiceCenter.GetService<IAssetManager>().Load("config/xml/food.xml", AssetType.Text))
            {
                FoodConfig.Parse(LoadXml(asset.Cast<string>(), "config"));
                FoodConfig.SwitchMap((uint)id);
            }
        }

results matching ""

    No results matching ""