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

边栏推荐
- uploads-labs靶场(附源码分析)(更新中)
- 面试官:JVM如何分配和回收堆外内存
- Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
- 关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM
- Everyone in remote office works together to realize cooperative editing of materials and development of documents | community essay solicitation
- Initial test of scikit learn Library
- AcWing 第58 场周赛
- [statement] about searching sogk1997 and finding many web crawler results
- [solved] access denied for user 'root' @ 'localhost' (using password: yes)
- Characteristic polynomial and constant coefficient homogeneous linear recurrence
猜你喜欢

Multithread 02 thread join

【Proteus仿真】74HC595+74LS154驱动显示16X16点阵

Redis installation under windows and Linux systems

Stm32f103c8t6 firmware library lighting

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

一台服务器最大并发 tcp 连接数多少?65535?

于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日

2022爱分析· 国央企数字化厂商全景报告

面试官:JVM如何分配和回收堆外内存

拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
随机推荐
一台服务器最大并发 tcp 连接数多少?65535?
Leetcode binary search tree
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
TCP congestion control details | 3 design space
NSQ源码安装运行过程
[combinatorics] combinatorial identity (sum of combinatorial identity products 1 | sum of products 1 proof | sum of combinatorial identity products 2 | sum of products 2 proof)
Mixlab编辑团队招募队友啦~~
nifi从入门到实战(保姆级教程)——flow
利用MySQL中的乐观锁和悲观锁实现分布式锁
疫情常态化大背景下,关于远程办公的思考|社区征文
Unity project optimization case 1
PHP secondary domain name session sharing scheme
Eleven requirements for test management post
ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
TCP擁塞控制詳解 | 3. 設計空間
记一次jar包冲突解决过程
Characteristic polynomial and constant coefficient homogeneous linear recurrence
手机注册股票开户安全吗 开户需要钱吗
初试scikit-learn库