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

边栏推荐
- Colab works with Google cloud disk
- 利用MySQL中的乐观锁和悲观锁实现分布式锁
- [combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
- ThreeJS 第二篇:顶点概念、几何体结构
- Stm32f103c8t6 firmware library lighting
- PHP CI (CodeIgniter) log level setting
- MB10M-ASEMI整流桥MB10M
- 2022爱分析· 国央企数字化厂商全景报告
- 8 cool visual charts to quickly write the visual analysis report that the boss likes to see
- Pyinstaller is not an internal or external command, nor is it a runnable program or batch file
猜你喜欢

Uploads labs range (with source code analysis) (under update)

探索Cassandra的去中心化分布式架构

8 cool visual charts to quickly write the visual analysis report that the boss likes to see

Multithread 02 thread join

How to thicken the brush in the graphical interface

From the 18th line to the first line, the new story of the network security industry
![[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix](/img/d6/3c21c25f1c750f17aeb871124e80f4.png)
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix

Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN
![[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)

近视:摘镜or配镜?这些问题必须先了解清楚
随机推荐
远程文件包含实操
深入理解 SQL 中的 Grouping Sets 语句
MongoDB 的安装和基本操作
Using optimistic lock and pessimistic lock in MySQL to realize distributed lock
Leetcode binary search tree
Cocos Creator 2.x 自动打包(构建 + 编译)
Threejs Part 2: vertex concept, geometry structure
Initial test of scikit learn Library
Is it safe to open an account with tongdaxin?
"Everyday Mathematics" serial 56: February 25
How to use AAB to APK and APK to AAB of Google play apps on the shelves
Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!
面试官:JVM如何分配和回收堆外内存
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
Nifi from introduction to practice (nanny level tutorial) - flow
Unity项目优化案例一
Pychart error updating package list: connect timed out
Golang decorator mode and its use in NSQ
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (III)
Svn usage specification