ET6.0 配置档增加List和Dictionary配置支持

解决点

看了ET的转表工具源码,发现不支持List和Dictionary的配置,但是很多时候其实,字典配置是非常有用的,所以增加支持

实现

  1. 在ExcelExporter项目的Program.cs文件类型转换方法增加
        private static string Convert(string type, string value)
        {
            switch (type)
            {
                case "int[]":
                case "int32[]":
                case "long[]":
                    return $"[{value}]";
                case "string[]":
                    return $"[{value}]";
                case "int":
                case "int32":
                case "int64":
                case "long":
                case "float":
                case "double":
                    return value;
                case "string":
                    return $"\"{value}\"";
                case "bool":
                    return $"\"{value == "1"}\"";
                default:
                    if (type.StartsWith("List<"))
                        return $"[{value}]";
                    else if (type.StartsWith("Dictionary<"))
                        return "{" + $"{value}" + "}";
                    Console.WriteLine($"不支持此类型: {type}");
                    Console.ReadLine();
                    throw new Exception($"不支持此类型: {type}");
            }
        }
  1. 数据档流程是 Excel -> json -> bytes
    json -> bytes 使用的是 protobuf的Serializers不支持Dictionary中存在object
修改源码  Unity\Assets\ThirdParty\protobuf-net\Serializers\TypeSerializer.cs 146行
 if (actualType == forType) return null; 
修改为
 if (actualType == forType || forType==typeof(object)) return null;

效果图

Excel配置表图

转出的json图

转出的bytes图
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容