예제 #1
0
 /// <summary>
 /// 读取数据表。
 /// </summary>
 /// <param name="dataTable">数据表。</param>
 /// <param name="dataTableAssetName">数据表资源名称。</param>
 /// <param name="dataTableBytes">数据表二进制流。</param>
 /// <param name="startIndex">数据表二进制流的起始位置。</param>
 /// <param name="length">数据表二进制流的长度。</param>
 /// <param name="userData">用户自定义数据。</param>
 /// <returns>是否读取数据表成功。</returns>
 public override bool ReadData(DataTableBase dataTable, string dataTableAssetName, byte[] dataTableBytes, int startIndex, int length, object userData)
 {
     if (dataTableAssetName.EndsWith(BytesAssetExtension, StringComparison.Ordinal))
     {
         return(dataTable.ParseData(dataTableBytes, startIndex, length, userData));
     }
     else
     {
         return(dataTable.ParseData(Utility.Converter.GetString(dataTableBytes, startIndex, length), userData));
     }
 }
예제 #2
0
        /// <summary>
        /// 读取数据表。
        /// </summary>
        /// <param name="dataTable">数据表。</param>
        /// <param name="dataTableAssetName">数据表资源名称。</param>
        /// <param name="dataTableAsset">数据表资源。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>是否读取数据表成功。</returns>
        public override bool ReadData(DataTableBase dataTable, string dataTableAssetName, object dataTableAsset, object userData)
        {
            TextAsset dataTableTextAsset = dataTableAsset as TextAsset;

            if (dataTableTextAsset != null)
            {
                if (dataTableAssetName.EndsWith(BytesAssetExtension, StringComparison.Ordinal))
                {
                    return(dataTable.ParseData(dataTableTextAsset.bytes, userData));
                }
                else
                {
                    return(dataTable.ParseData(dataTableTextAsset.text, userData));
                }
            }

            Log.Warning("Data table asset '{0}' is invalid.", dataTableAssetName);
            return(false);
        }