From 0095de8b57251082e8c98eee70d18748359c444a Mon Sep 17 00:00:00 2001 From: dingxiaowei <1213250243@qq.com> Date: Sun, 11 Sep 2022 19:20:27 +0800 Subject: [PATCH] Update README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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;