当前位置:网站首页>Unreal_ Datatable implements ID self increment and sets rowname
Unreal_ Datatable implements ID self increment and sets rowname
2022-07-03 16:26:00 【SimpleCloud94】
Implement... In the editor id Self increasing

For example, the picture above , Click on Add when , Realization Id Automatic addition 1, How to achieve it ?
The method is as follows :
- When defining the structure as shown in the figure , stay Id Property column , Assign a value when initializing the structure attribute

Define a static method , Dynamic acquisition in static method
DatatableData in tableGet
IdThere are many methods of attribute value , The following is only a reference
int32 UDataTableHelperUtils::GetDataTableLastIdNum()
{
int CardId = 0;
UDataTable* DataTable = LoadObject<UDataTable>(nullptr,TEXT("DataTable'/Game/DataTables/DT_Cards.DT_Cards'"));
if(!DataTable) return CardId;
TArray<TArray<FString>> TableData = DataTable->GetTableData();
#if WITH_EDITOR
for(int i=0; i< TableData.Num();i++)
{
FDataTableEditorUtils::RenameRow(DataTable,*TableData[i][0],*TableData[i][1]);
}
#endif
DataTable->Modify();
// UEditorAssetLibrary::SaveAsset(TEXT("DataTable'/Game/DataTables/DT_Cards.DT_Cards'"),false);
const FString RowId = TableData[TableData.Num()-1][1];
CardId = FCString::Atoi(*RowId);
return CardId;
}
among DataTable->GetTableData() Method is a two-dimensional array , Row and column structure . The default column subscript is 1 Represent id The value of the property
among const FString RowId = TableData[TableData.Num()-1][1]; Getting is the last line Id The attribute value
Dynamic modification RowName
If you use the code level , Dynamically add a record . have access to FDataTableEditorUtils, This category mainly belongs to UnrealEd modular , It cannot be used at runtime .

FDataTableEditorUtils::AddRow()
At runtime or Runtime In mode , It can also be done through UDataTable Methods AddRow() Implementation add , But no reset is provided at runtime RowName Methods .
In the above code , This method is modified RowName It's not a very efficient way , This can be adjusted according to the actual situation , The author tests under the editor , Regardless of performance
for(int i=0; i< TableData.Num();i++)
{
FDataTableEditorUtils::RenameRow(DataTable,*TableData[i][0],*TableData[i][1]);
}
Last, last , If you think this article helps you , Please subsidize this friend's food , thank you !

边栏推荐
- MongoDB 的安装和基本操作
- Caching mechanism of Hibernate / session level caching mechanism
- Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day
- Explore Netease's large-scale automated testing solutions see here see here
- Mixlab编辑团队招募队友啦~~
- Break through 1million, sword finger 2million!
- Svn usage specification
- 近视:摘镜or配镜?这些问题必须先了解清楚
- First knowledge of database
- Record a jar package conflict resolution process
猜你喜欢

Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword

初试scikit-learn库
![[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)](/img/68/3721975cf33fcfacc28dc4d3d6a5ca.jpg)
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)

【Proteus仿真】8×8LED点阵屏仿电梯数字滚动显示

MongoDB 的安装和基本操作
![[list to map] collectors Tomap syntax sharing (case practice)](/img/ac/e02deb1cb237806d357a88fb812852.jpg)
[list to map] collectors Tomap syntax sharing (case practice)

拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。

How to thicken the brush in the graphical interface

Mongodb installation and basic operation
![SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]](/img/3b/7523eca5bbcdbba29d9b7f6e4791a5.jpg)
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
随机推荐
特征多项式与常系数齐次线性递推
[combinatorics] non descending path problem (outline of non descending path problem | basic model of non descending path problem | non descending path problem expansion model 1 non origin starting poi
Low level version of drawing interface (explain each step in detail)
June to - -------
[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
远程文件包含实操
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Visual SLAM algorithms: a survey from 2010 to 2016
The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)
Cocos Creator 2.x 自动打包(构建 + 编译)
First knowledge of database
Hibernate的缓存机制/会话级缓存机制
App mobile terminal test [4] APK operation
消息队列消息丢失和消息重复发送的处理策略
Svn usage specification
Unity project optimization case 1
切入点表达式
初试scikit-learn库
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)