{"id":70,"date":"2020-07-14T20:09:53","date_gmt":"2020-07-14T11:09:53","guid":{"rendered":"http:\/\/strangechu.com\/?p=70"},"modified":"2020-08-31T11:33:20","modified_gmt":"2020-08-31T02:33:20","slug":"ue4-%e8%99%95%e7%90%86datatable%e3%80%80import%e7%9a%84%e8%b3%87%e6%96%99%e6%a0%bc%e5%bc%8f%e8%bd%89%e6%8f%9b","status":"publish","type":"post","link":"https:\/\/strangechu.com\/?p=70","title":{"rendered":"[UE4] \u8655\u7406DataTable\u7684Import\u8cc7\u6599\u683c\u5f0f\u8f49\u63db"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u554f\u984c<\/h2>\n\n\n\n<p>\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u542b\u6709Enum\u7684DataTable\u5b9a\u7fa9\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UENUM()\nenum class EAnimalType : int32\n{\n\tChicken,\n\tDuck,\n\tBird,\n};\n\nUSTRUCT(BlueprintType)\nstruct BREAKWORLD_API FAnimalDataRow : public FTableRowBase\n{\n\tGENERATED_BODY()\n\n\tUPROPERTY()\n\tEAnimalType Type;\n\n\tUPROPERTY()\n\tFString AnimalName;\n};<\/code><\/pre>\n\n\n\n<p>\u4f46\u662f\u539f\u59cb\u8cc7\u6599\u662fCSV\u6216\u662fJson\u6a94\uff0c\u6b64\u6642\u5982\u679c\u4f7f\u7528UE4\u7684Import\u5de5\u5177\uff0cint\u5230enum\u5c07\u4e0d\u6703\u81ea\u52d5\u8f49\u63db\u800c\u7121\u6cd5\u53d6\u5f97\u6b63\u78ba\u7684enum\u503c\u3002<\/p>\n\n\n\n<p>\u8feb\u65bc\u7121\u5948\uff0c\u4e4b\u524d\u7684\u505a\u6cd5\u662f\u53ea\u80fd\u66ab\u6642\u5b58\u70baint\uff0c\u7b49\u5230\u8981\u4f7f\u7528\u8cc7\u6599\u6642\u518d\u624b\u52d5\u8b8a\u63db\u3002\u7136\u800c\u9019\u9ebc\u505a\u7684\u8a71\u7de8\u8f2f\u5668\u5167\u7684DataTable\u6703\u9577\u9019\u500b\u6a23\u5b50\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"242\" height=\"82\" src=\"https:\/\/i0.wp.com\/strangechu.com\/wp-content\/uploads\/2020\/07\/image.png?resize=242%2C82&#038;ssl=1\" alt=\"\" class=\"wp-image-71\"\/><\/figure><\/div>\n\n\n\n<p>\u7531\u65bc\u6211\u5011\u662f\u4ee5int\u5132\u5b58\u7684\uff0c\u56e0\u6b64\u7121\u6cd5\u770b\u5230enum\u7684\u503c\u3002\u7576\u8cc7\u6599\u591a\u7684\u6642\u5019\u6578\u5b57\u6703\u96e3\u4ee5\u8fa8\u8b58\uff0c\u6709\u6c92\u6709\u66f4\u597d\u7684\u8655\u7406\u65b9\u6cd5\u5462\uff1f<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528 OnPostDataImport \u8655\u7406\u8cc7\u6599\u8f49\u63db<\/h2>\n\n\n\n<p>\u7d50\u679c\u5728\u5f15\u64ce\u7a0b\u5f0f\u78bc\u767c\u73fe\u4e86\u9019\u500b\u51fd\u5f0f \uff0c\u6703\u5728Import\u7d50\u675f\u5f8c\u88ab\u547c\u53eb\uff0c\u53ef\u4ee5override\u9019\u500b\u51fd\u5f0f\u4f86\u505a\u8cc7\u6599\u8f49\u63db\u3002\u5be6\u969b\u505a\u7684\u4fee\u6539\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>USTRUCT(BlueprintType)\nstruct BREAKWORLD_API FAnimalDataRow : public FTableRowBase\n{\n\tGENERATED_BODY()\n\n\tUPROPERTY()\n\tEAnimalType Type;\n\t\n\tUPROPERTY()\n\tint32 TypeTemp;\n\n\tUPROPERTY()\n\tFString AnimalName;\n\n\tvirtual void OnPostDataImport(const UDataTable* InDataTable, const FName InRowName, TArray&lt;FString>&amp; OutCollectedImportProblems) override;\n};\n\nvoid FAnimalDataRow::OnPostDataImport(const UDataTable* InDataTable, const FName InRowName, TArray&lt;FString>&amp; OutCollectedImportProblems)\n{\n\tType = static_cast&lt;EAnimalType>(TypeTemp);\n}\n<\/code><\/pre>\n\n\n\n<p>\u5728\u5be6\u4f5c\u7684\u51fd\u5f0f\u4e2d\u5c07\u65b0\u589e\u7684\u66ab\u6642\u8b8a\u6578int\u7684TypeTemp\u8f49\u63db\u6210enum\u7684Type\u3002\u5be6\u969b\u4fee\u6539\u5f8cImport\u8a66\u8a66\u770b\u5f8c\uff0c\u96d6\u7136Enum\u6709\u6b63\u78ba\u8f49\u63db\uff0c\u4f46\u662f\u51fa\u73fe\u4e86\u932f\u8aa4\uff1f<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"211\" src=\"https:\/\/i0.wp.com\/strangechu.com\/wp-content\/uploads\/2020\/07\/image-1.png?resize=640%2C211&#038;ssl=1\" alt=\"\" class=\"wp-image-72\"\/><\/figure>\n\n\n\n<p>\u539f\u4f86\u5f15\u64ce\u5167\u8a2d\u5b9a\u53ea\u8981\u6709\u627e\u4e0d\u5230\u7684Column \uff08Type\uff09 \u5c31\u6703\u986f\u793a\u9019\u500b\u8b66\u544a\u8a0a\u606f\uff0c\u641c\u5c0b\u4e86\u4e00\u4e0b\u8b66\u544a\u51fa\u73fe\u7684\u5730\u65b9\uff0c\u767c\u73fe\u53ef\u4ee5\u4f7f\u7528DataTableImportOptional\u9019\u500bMetaData\u4f86\u8868\u793a\u9019\u500bProperty\u662f\u4e0d\u9700\u8981\u88abimport\u7684\uff0c\u5728import\u6aa2\u67e5\u7684\u6642\u5019\u5c31\u6703\u88ab\u5ffd\u7565\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c0dProperty\u4f7f\u7528MetaData DataTableImportOptional\u4f86\u8ff4\u907fImport\u6aa2\u67e5<\/h2>\n\n\n\n<p>\u5be6\u969b\u4fee\u6539Enum Property\uff0c\u65b0\u589eMetaData DataTableImportOptional\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tUPROPERTY(meta = (DataTableImportOptional))\n\tEAnimalType Type;<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"323\" height=\"93\" src=\"https:\/\/i0.wp.com\/strangechu.com\/wp-content\/uploads\/2020\/07\/image-4.png?resize=323%2C93&#038;ssl=1\" alt=\"\" class=\"wp-image-75\"\/><\/figure><\/div>\n\n\n\n<p>\u932f\u8aa4\u6d88\u5931\uff0c\u4efb\u52d9\u5b8c\u6210\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u304a\u307e\u3051<\/h2>\n\n\n\n<p>\u660e\u660e\u662f\u883b\u6709\u7528\u7684\u529f\u80fd\uff0c\u537b\u5b8c\u5168\u6c92\u51fa\u73fe\u5728\u5b98\u65b9\u6587\u4ef6\u4e0a\uff0c\u53ea\u6709\u57284.13\u7684Release Note\u4e0a\u51fa\u73fe\u5e7e\u884c\u800c\u5df2\uff0c\u6709\u9ede\u53ef\u60dc\u554a\uff0c\u5e0c\u671b\u770b\u5230\u9019\u7bc7\u7684\u4eba\u53ef\u4ee5\u77e5\u9053\u6709\u9019\u500b\u529f\u80fdXD<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/strangechu.com\/wp-content\/uploads\/2020\/07\/image-2.png?resize=640%2C92&#038;ssl=1\" alt=\"\" class=\"wp-image-73\" width=\"640\" height=\"92\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c3\u8003\u8cc7\u6599<\/h2>\n\n\n\n<p><a href=\"https:\/\/docs.unrealengine.com\/ja\/Support\/Builds\/ReleaseNotes\/2016\/4_13\/index.html\">https:\/\/docs.unrealengine.com\/ja\/Support\/Builds\/ReleaseNotes\/2016\/4_13\/index.html<\/a><\/p>\n\n\n\n<p>Engine\/Source\/RuntimeEngine\/Private\/DataTableJSON.cpp<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u554f\u984c \u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u542b\u6709Enum\u7684DataTable\u5b9a\u7fa9\u5982\u4e0b \u4f46\u662f\u539f\u59cb\u8cc7\u6599\u662fCSV\u6216\u662fJson\u6a94\uff0c\u6b64\u6642\u5982\u679c\u4f7f\u7528 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[4,2],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-ue4","category-2"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paZrII-18","_links":{"self":[{"href":"https:\/\/strangechu.com\/index.php?rest_route=\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/strangechu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strangechu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strangechu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strangechu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70"}],"version-history":[{"count":2,"href":"https:\/\/strangechu.com\/index.php?rest_route=\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":82,"href":"https:\/\/strangechu.com\/index.php?rest_route=\/wp\/v2\/posts\/70\/revisions\/82"}],"wp:attachment":[{"href":"https:\/\/strangechu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strangechu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strangechu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}