当前位置:网站首页>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
Datatable
Data in tableGet
Id
There 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 !
边栏推荐
- Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
- 切入点表达式
- pycharm错Error updating package list: connect timed out
- Explore Cassandra's decentralized distributed architecture
- 无心剑中译泰戈尔《漂鸟集(1~10)》
- PHP二级域名session共享方案
- NSQ source code installation and operation process
- [combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
- Project -- high concurrency memory pool
- "Remake Apple product UI with Android" (3) - elegant statistical chart
猜你喜欢
【Proteus仿真】8×8LED点阵屏仿电梯数字滚动显示
探索Cassandra的去中心化分布式架构
Low level version of drawing interface (explain each step in detail)
初试scikit-learn库
QT串口ui设计和解决显示中文乱码
ThreeJS 第二篇:顶点概念、几何体结构
Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword
Unreal_DataTable 实现Id自增与设置RowName
记一次jar包冲突解决过程
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
随机推荐
【LeetCode】94. Middle order traversal of binary tree
Develop team OKR in the way of "crowdfunding"
相同切入点的抽取
利用MySQL中的乐观锁和悲观锁实现分布式锁
Basis of target detection (IOU)
用通达信炒股开户安全吗?
2022爱分析· 国央企数字化厂商全景报告
Batch files: list all files in a directory with relative paths - batch files: list all files in a directory with relative paths
2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
Caching mechanism of Hibernate / session level caching mechanism
Svn usage specification
PHP中register_globals参数设置
From the 18th line to the first line, the new story of the network security industry
Explore Netease's large-scale automated testing solutions see here see here
Break through 1million, sword finger 2million!
Mongodb installation and basic operation
Pointcut expression
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
SVN使用规范
TCP congestion control details | 3 design space