当前位置:网站首页>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 installation and basic operation
- 1287. Elements that appear more than 25% in an ordered array
- Using optimistic lock and pessimistic lock in MySQL to realize distributed lock
- Stm32f103c8t6 firmware library lighting
- 线程池执行定时任务
- [solved] access denied for user 'root' @ 'localhost' (using password: yes)
- 手机注册股票开户安全吗 开户需要钱吗
- QT串口ui设计和解决显示中文乱码
- Record windows10 installation tensorflow-gpu2.4.0
- 0214-27100 a day with little fluctuation
猜你喜欢
![[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

ThreeJS 第二篇:顶点概念、几何体结构

消息队列消息丢失和消息重复发送的处理策略

Mongodb installation and basic operation

跟我学企业级flutter项目:简化框架demo参考

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

Mb10m-asemi rectifier bridge mb10m

NSQ源码安装运行过程

Getting started with Message Oriented Middleware

探索Cassandra的去中心化分布式架构
随机推荐
面试之 top k问题
Break through 1million, sword finger 2million!
Threejs Part 2: vertex concept, geometry structure
Uploads labs range (with source code analysis) (under update)
[list to map] collectors Tomap syntax sharing (case practice)
ThreeJS 第二篇:顶点概念、几何体结构
Hibernate的缓存机制/会话级缓存机制
Mongodb installation and basic operation
消息队列消息丢失和消息重复发送的处理策略
Why does the std:: string operation perform poorly- Why do std::string operations perform poorly?
Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword
Eleven requirements for test management post
Project -- high concurrency memory pool
From the 18th line to the first line, the new story of the network security industry
PHP CI (CodeIgniter) log level setting
Visual SLAM algorithms: a survey from 2010 to 2016
切入点表达式
Pandora IOT development board learning (HAL Library) - Experiment 5 external interrupt experiment (learning notes)
Caching mechanism of Hibernate / session level caching mechanism
Embedded development: seven reasons to avoid open source software