protected override bool LoadDataTable(Type dataRowType, string dataTableName, string dataTableNameType, object dataTableAsset, object userData) { TextAsset textAsset = dataTableAsset as TextAsset; m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, textAsset.text); return(true); }
static int CreateDataTable(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.DataTableComponent), typeof(System.Type), typeof(string))) { UnityGameFramework.Runtime.DataTableComponent obj = (UnityGameFramework.Runtime.DataTableComponent)ToLua.ToObject(L, 1); System.Type arg0 = (System.Type)ToLua.ToObject(L, 2); string arg1 = ToLua.ToString(L, 3); GameFramework.DataTable.DataTableBase o = obj.CreateDataTable(arg0, arg1); ToLua.PushObject(L, o); return(1); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.DataTableComponent), typeof(System.Type), typeof(string), typeof(string))) { UnityGameFramework.Runtime.DataTableComponent obj = (UnityGameFramework.Runtime.DataTableComponent)ToLua.ToObject(L, 1); System.Type arg0 = (System.Type)ToLua.ToObject(L, 2); string arg1 = ToLua.ToString(L, 3); string arg2 = ToLua.ToString(L, 4); GameFramework.DataTable.DataTableBase o = obj.CreateDataTable(arg0, arg1, arg2); ToLua.PushObject(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityGameFramework.Runtime.DataTableComponent.CreateDataTable")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 加载数据表。 /// </summary> /// <param name="dataRowType">数据表行的类型。</param> /// <param name="dataTableName">数据表名称。</param> /// <param name="dataTableNameInType">数据表类型下的名称。</param> /// <param name="dataTableAssetName">数据表资源名称。</param> /// <param name="dataTableObject">数据表对象。</param> /// <param name="userData">用户自定义数据。</param> /// <returns>是否加载成功。</returns> protected override bool LoadDataTable(Type dataRowType, string dataTableName, string dataTableNameInType, string dataTableAssetName, object dataTableObject, object userData) { if (dataRowType == null) { Log.Warning("Data row type is invalid."); return(false); } TextAsset dataTableTextAsset = dataTableObject as TextAsset; if (dataTableTextAsset != null) { if (dataTableAssetName.EndsWith(BytesAssetExtension)) { m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, dataTableTextAsset.bytes); } else { m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, dataTableTextAsset.text); } return(true); } byte[] dataTableBytes = dataTableObject as byte[]; if (dataTableBytes != null) { if (dataTableAssetName.EndsWith(BytesAssetExtension)) { m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, dataTableBytes); } else { m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, Utility.Converter.GetString(dataTableBytes)); } return(true); } Log.Warning("Data table object '{0}' is invalid.", dataTableName); return(false); }
/// <summary> /// 加载数据表。 /// </summary> /// <param name="dataRowType">数据表行的类型。</param> /// <param name="dataTableName">数据表名称。</param> /// <param name="dataTableNameInType">数据表类型下的名称。</param> /// <param name="dataTableAsset">数据表资源。</param> /// <param name="loadType">数据表加载方式。</param> /// <param name="userData">用户自定义数据。</param> /// <returns>是否加载成功。</returns> protected override bool LoadDataTable(Type dataRowType, string dataTableName, string dataTableNameInType, object dataTableAsset, LoadType loadType, object userData) { TextAsset textAsset = dataTableAsset as TextAsset; if (textAsset == null) { Log.Warning("Data table asset '{0}' is invalid.", dataTableName); return(false); } if (dataRowType == null) { Log.Warning("Data row type is invalid."); return(false); } switch (loadType) { case LoadType.Text: m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, textAsset.text); break; case LoadType.Bytes: m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, textAsset.bytes); break; case LoadType.Stream: using (MemoryStream stream = new MemoryStream(textAsset.bytes, false)) { m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, stream); } break; default: Log.Warning("Unknown load type."); return(false); } return(true); }
/// <summary> /// 加载数据表。 /// </summary> /// <param name="dataRowType">数据表行的类型。</param> /// <param name="dataTableName">数据表名称。</param> /// <param name="dataTableNameInType">数据表类型下的名称。</param> /// <param name="dataTableAsset">数据表资源。</param> /// <param name="userData">用户自定义数据。</param> /// <returns>加载是否成功。</returns> protected override bool LoadDataTable(Type dataRowType, string dataTableName, string dataTableNameInType, object dataTableAsset, object userData) { TextAsset textAsset = dataTableAsset as TextAsset; if (textAsset == null) { Log.Warning("Data table asset '{0}' is invalid.", dataTableName); return(false); } if (dataRowType == null) { Log.Warning("Data row type is invalid."); return(false); } m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, textAsset.text); return(true); }
/// <summary> /// 加载数据表。 /// </summary> /// <param name="dataRowType">数据表行的类型。</param> /// <param name="dataTableName">数据表名称。</param> /// <param name="dataTableNameInType">数据表类型下的名称。</param> /// <param name="dataTableObject">数据表对象。</param> /// <param name="loadType">数据表加载方式。</param> /// <param name="userData">用户自定义数据。</param> /// <returns>是否加载成功。</returns> protected override bool LoadDataTable(Type dataRowType, string dataTableName, string dataTableNameInType, object dataTableObject, LoadType loadType, object userData) { if (dataRowType == null) { Log.Warning("Data row type is invalid."); return(false); } TextAsset dataTableTextAsset = dataTableObject as TextAsset; if (dataTableTextAsset != null) { switch (loadType) { case LoadType.TextFromAsset: m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, dataTableTextAsset.text); return(true); case LoadType.BytesFromAsset: m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, dataTableTextAsset.bytes); return(true); case LoadType.StreamFromAsset: using (MemoryStream stream = new MemoryStream(dataTableTextAsset.bytes, false)) { m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, stream); return(true); } default: Log.Warning("Not supported load type '{0}' for data table asset."); return(false); } } byte[] dataTableBytes = dataTableObject as byte[]; if (dataTableBytes != null) { switch (loadType) { case LoadType.TextFromBinary: m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, Utility.Converter.GetString(dataTableBytes)); return(true); case LoadType.BytesFromBinary: m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, dataTableBytes); return(true); case LoadType.StreamFromBinary: using (MemoryStream stream = new MemoryStream(dataTableBytes, false)) { m_DataTableComponent.CreateDataTable(dataRowType, dataTableNameInType, stream); return(true); } default: Log.Warning("Not supported load type '{0}' for data table binary."); return(false); } } Log.Warning("Data table object '{0}' is invalid.", dataTableName); return(false); }