? ,,

新锐科创官网-专业室内外高精度人员定位系统厂家及服务商

聯系我們

給我們留言

聯系我們

地址:福建省晉江市青陽街道洪山路國際工業設計園納金網

郵箱:info@narkii.com

電話:0595-82682267

(周一到周五, 周六周日休息)

當前位置:主頁 > 3D教程 > 圖文教程

UE4引擎的夸平臺讀寫Excel的組件:DataTable

來源: 52vr | 責任編輯:傳說的落葉 | 發布時間: 2019-06-04 08:26 | 瀏覽量:

[UE4]引擎自身提供的一種夸平臺讀寫Excel的組件:DataTable

 

UE4自身提供的一種讀寫文件的組件:UDataTable。好處就是不用自己寫fopen、fclose等 c++ stl API相關的邏輯,避開不同平臺的差異;壞處就是你想要的功能DataTable沒有實現,那么還得用fopen自己發揮。

 

讀寫excel需要導出為CSV文件,目前還不支持*.XLS格式。

 

下面官方文檔中關于用C++代碼定義行結構的用法沒有具體說明:

如果是藍圖創建DataTable,那么行結構Struct也可以用UE4提供的Struct組件,創建方式是:add new -》 Blueprints -》 Structure,然后再這個Structure中設置行結構。

如果是用C++代碼創建DataTable,直接new C++ class,選擇繼承DataTable。另外FTableRowBase可以直接定義在自定義DataTable的頭文件中,例如:

 
  1. #pragma once  
  2.   
  3. #include "Engine/DataTable.h"  
  4. #include "CharactersDT.generated.h"  
  5.   
  6. USTRUCT(BlueprintType)  
  7. struct FLevelUpData : public FTableRowBase  
  8. {  
  9.     GENERATED_USTRUCT_BODY()  
  10.   
  11. public:  
  12.   
  13.     FLevelUpData()  
  14.         : XPtoLvl(0)  
  15.         , AdditionalHP(0)  
  16.     {}  
  17.   
  18.     /** The 'Name' column is the same as the XP Level */  
  19.   
  20.     /** XP to get to the given level from the previous level */  
  21.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LevelUp)  
  22.         int32 XPtoLvl;  
  23.   
  24.     /** Extra HitPoints gained at this level */  
  25.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LevelUp)  
  26.         int32 AdditionalHP;  
  27.   
  28.     /** Icon to use for Achivement */  
  29.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LevelUp)  
  30.         TAssetPtr<UTexture> AchievementIcon;  
  31. };  
 

 

Using excel to store gameplay data - DataTables

https://wiki.unrealengine.com/Using_excel_to_store_gameplay_data_-_DataTables

 

Data Driven Gameplay Elements

https://docs.unrealengine.com/latest/INT/Gameplay/DataDriven/index.html

 

Driving Gameplay with Data from Excel

https://forums.unrealengine.com/showthread.php?12572-Driving-Gameplay-with-Data-from-Excel

 

用藍圖操作DataTable的方法:
Unreal Engine, Datatables for Blueprints (build & Use)

https://www.youtube.com/watch?v=a8jMl69alrg

Excel to Unreal

https://www.youtube.com/watch?v=WLv67ddnzN0

 

如何用C++代碼動態加載*.CSV

如果你的表格很少的話可以使用這個自帶的DataTable,如果表格很多且會頻繁改動,那么每次改動后都要手動在UE編輯器中一個一個操作,所以,建議用C++動態加載*.csv:

 
  1. FString csvFile = FPaths::GameContentDir() + "Downloads\\DownloadedFile.csv";  
  2. if (FPaths::FileExists(csvFile ))  
  3. {  
  4.     FString FileContent;  
  5.     //Read the csv file  
  6.     FFileHelper::LoadFileToString(FileContent, *csvFile );  
  7.     TArray<FString> problems = YourDataTable->CreateTableFromCSVString(FileContent);  
  8.   
  9.     if (problems.Num() > 0)  
  10.     {  
  11.         for (int32 ProbIdx = 0; ProbIdx < problems.Num(); ProbIdx++)  
  12.         {          
  13.             //Log the errors  
  14.         }  
  15.     }  
  16.     else  
  17.     {  
  18.         //Updated Successfully  
  19.     }  
  20. }  

 參考自:

https://answers.unrealengine.com/questions/156354/how-to-load-the-csv-datatable-dynamically.html


相關文章
網友評論

您需要登錄后才可以發帖 登錄 | 立即注冊

關閉

全部評論:0條

推薦
熱門
主站蜘蛛池模板: 欧美高清的视频 | 亚洲精品视频在线 | 日韩免费高清一级毛片久久 | 亚洲国产日韩精品一区二区三区 | 国产黄色在线视频 | 又粗又猛又黄又爽无遮挡 | 亚洲嫩草影院久久精品 | 国产成品精品午夜视频 | 韩日午夜在线资源一区二区 | 成人欧美精品久久久久影院 | 国产激情视频一区二区三区 | 精品久久久久久中文 | 久久精品国产免费观看 | 国产不卡视频在线观看 | 国产乱子伦视频一区二区三区 | 亚洲视频在线不卡 | 亚洲成在人线影视天堂网 | av无码久久久久不卡免费网站 | 亚洲天堂一区 | 国产成 人 综合 亚洲网 | 久久人妻内射无码一区三区 | 侵犯人妻女教师中文字幕 | 一区二区乱子伦在线播放 | 国产亚洲日韩av在线播放不卡 | 免费a级黄色片 | 可以免费观看的一级片 | 国产色婷婷精品综合在线 | 久久亚洲精品成人av无码网站 | 亚洲第一av导航av尤物 | 疯狂添女人下部视频免费 | 久久久久久人妻一区精品 | 精品乱码一区内射人妻无码 | 中文字幕在线播放不卡 | 日产2021免费一二三四区在线 | 99热这里有免费国产精品 | 老司机亚洲精品影视www | 成人1000部免费观看视频 | 欧美粉嫩免费视频播放 | 午夜老司机福利 | 国产精品成人免费观看 | 国产欧美一区二区三区精品 |