diff --git a/README.md b/README.md index 6e8b7e5..d51a7ee 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,28 @@ else Debug.LogError("数据读取错误"); } ``` + +#### 泛型读表 +``` +T ReadTable(string tableName) where T : IBinarySerializable, new() +{ +var bytes = LoadTextAsset(tableName); +if (bytes != null) +{ + IBinarySerializable data = new T(); + var readOK = FileManager.ReadBinaryDataFromBytes(bytes.bytes, ref data); + if (readOK) + { + return (T)data; + } + else + { + Debug.LogError($"{tableName}解析出错 类型{typeof(T)}"); + } +} +return default(T); +} +``` ##### 查询数据 ``` var avatarguideTest = (avatarguideTestConfig)newavList;