当前位置:网站首页>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 !

边栏推荐
- 线程池执行定时任务
- How to initialize views when loading through storyboards- How is view initialized when loaded via a storyboard?
- 六月 致 -.-- -..- -
- MB10M-ASEMI整流桥MB10M
- Mysql 将逗号隔开的属性字段数据由列转行
- Mb10m-asemi rectifier bridge mb10m
- Cocos Creator 2.x 自动打包(构建 + 编译)
- Why does the std:: string operation perform poorly- Why do std::string operations perform poorly?
- 记一次jar包冲突解决过程
- Unity项目优化案例一
猜你喜欢

Mysql 单表字段重复数据取最新一条sql语句

Myopia: take off or match glasses? These problems must be understood clearly first
![[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](/img/81/59ed6bebf5d85e9eb71bd4ca261309.jpg)
[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
![[statement] about searching sogk1997 and finding many web crawler results](/img/1a/8ed3ca0030ea227adcd95e8b306aca.png)
[statement] about searching sogk1997 and finding many web crawler results

Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)

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

How can technology managers quickly improve leadership?

Explore Cassandra's decentralized distributed architecture

Mixlab编辑团队招募队友啦~~

uploads-labs靶场(附源码分析)(更新中)
随机推荐
TCP congestion control details | 3 design space
Nine ways to define methods in scala- Nine ways to define a method in Scala?
【Proteus仿真】74HC595+74LS154驱动显示16X16点阵
Hibernate的缓存机制/会话级缓存机制
14 topics for performance interviews between superiors and subordinates (4)
利用MySQL中的乐观锁和悲观锁实现分布式锁
Pychart error updating package list: connect timed out
Mysql 将逗号隔开的属性字段数据由列转行
Effect of ARP package on FTP dump under vxworks-6.6 system
如何在本机搭建SVN服务器
Record a jar package conflict resolution process
NSQ source code installation and operation process
The mixlab editing team is recruiting teammates~~
[web security] - [SQL injection] - error detection injection
Is it safe to open an account with tongdaxin?
Colab works with Google cloud disk
Golang 匿名函数使用
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
[list to map] collectors Tomap syntax sharing (case practice)
Expression of request header in different countries and languages