{"id":3448,"date":"2022-05-25T15:07:53","date_gmt":"2022-05-25T13:07:53","guid":{"rendered":"https:\/\/store.algosyntax.com\/?post_type=asx-lms-tutorial-cpt&#038;p=3448"},"modified":"2026-03-09T14:16:34","modified_gmt":"2026-03-09T12:16:34","slug":"tutorial-ue5-add-reimport-support-to-custom-asset","status":"publish","type":"asx-lms-tutorial-cpt","link":"https:\/\/store.algosyntax.com\/tutorials\/unreal-engine\/tutorial-ue5-add-reimport-support-to-custom-asset\/","title":{"rendered":"[Tutorial] UE5 Add Reimport Support to Custom Asset"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3448\" class=\"elementor elementor-3448\" data-elementor-post-type=\"asx-lms-tutorial-cpt\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-747f7b0 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"747f7b0\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a4c2629\" data-id=\"a4c2629\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5dd9991 elementor-widget elementor-widget-text-editor\" data-id=\"5dd9991\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>In this tutorial, we will cover adding reimport functionality to overwrite existing custom <a href=\"https:\/\/docs.unrealengine.com\/5.0\/en-US\/working-with-assets-in-unreal-engine\/\" target=\"_blank\" rel=\"noopener\">assets in unreal engine<\/a>. We assume that at this point you have a custom asset created using UFactory and we will be continuing from there. This is an extension of <a href=\"https:\/\/store.algosyntax.com\/tutorials\/unreal-engine\/tutorial-ue5-how-to-create-your-custom-asset\/\">how to create a custom asset type in unreal engine<\/a> tutorial. We have defined a key variable for file path in that tutorial and we assume you have that variable in your UFactory child class.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e572624 elementor-widget elementor-widget-heading\" data-id=\"e572624\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">1.Inherit from FReimportHandler class<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ec8d88a elementor-widget elementor-widget-text-editor\" data-id=\"ec8d88a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>The first thing you want to do is extend your custom UFactory child and inherit from <a href=\"https:\/\/docs.unrealengine.com\/4.27\/en-US\/API\/Editor\/UnrealEd\/FReimportHandler\/\" target=\"_blank\" rel=\"noopener\">FReimportHandler<\/a> class. This class will add support to handle all the reimport functionality for our custom asset. My preferred way to do this is with multiple inheritance. That is; inherit from both <a href=\"https:\/\/docs.unrealengine.com\/4.27\/en-US\/API\/Editor\/UnrealEd\/Factories\/UFactory\/\" target=\"_blank\" rel=\"noopener\">UFactory<\/a> and FReimportHandler classes at the same time like this:\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-da3e07d elementor-widget elementor-widget-code-highlight\" data-id=\"da3e07d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>UCLASS()\r\nclass UBcgAssetFactory : public UFactory , public FReimportHandler\r\n{\r\n        \/\/Function Overrides here;\r\n}<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-083b5ab elementor-widget elementor-widget-heading\" data-id=\"083b5ab\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">2. Override FReimportHandler Virtual Functions<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cfce8cb elementor-widget elementor-widget-text-editor\" data-id=\"cfce8cb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>There are 3 key virtual functions that need to be overridden in order to support Reimport functionality for your custom asset. These are:<\/p><p>The <a href=\"https:\/\/docs.unrealengine.com\/4.27\/en-US\/API\/Editor\/UnrealEd\/FReimportHandler\/CanReimport\/\" target=\"_blank\" rel=\"noopener\">CanReimport() function<\/a>, returns a bool to signal if the asset can be reimported or not.<\/p><p>The <a href=\"https:\/\/docs.unrealengine.com\/4.27\/en-US\/API\/Editor\/UnrealEd\/FReimportHandler\/SetReimportPaths\/1\/index.html\" target=\"_blank\" rel=\"noopener\">SetReimportPaths() function<\/a>, sets the new paths.\u00a0<\/p><p>The <a href=\"https:\/\/docs.unrealengine.com\/4.27\/en-US\/API\/Editor\/UnrealEd\/FReimportHandler\/Reimport\/1\/index.html\" target=\"_blank\" rel=\"noopener\">Reimport() function<\/a>, is the actual implementation of the importation process.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3861eb1 elementor-widget elementor-widget-code-highlight\" data-id=\"3861eb1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>\t\/\/Should return true\r\n\tvirtual bool CanReimport(UObject* Obj, TArray<FString>& OutFilenames)  override;\r\n\r\n\tvirtual void SetReimportPaths(UObject* Obj, const TArray<FString>& NewReimportPaths) override;\r\n\r\n\tvirtual EReimportResult::Type Reimport(UObject* Obj) override;<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5aca8c1 elementor-widget elementor-widget-heading\" data-id=\"5aca8c1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">a. The SetReimportPaths() function <\/h3>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c7b8d4b elementor-widget elementor-widget-text-editor\" data-id=\"c7b8d4b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>This function is called before the Reimport function. When a user clicks the &#8220;Reimport&#8221; button, unreal engine will present them with a dialog to select a file. It could be any file, meaning a different file on disk apart from the original used to create the initial asset. Maybe the original was renamed. <br \/><br \/>The variable NewImportPaths gives the developer a chance to do something with the newly selected file&#8217;s path. In our case, it gives us the chance to change SourceBcgFile(path) to the newly selected file path. Don&#8217;t get confused by the array, just select the first element [0] if you&#8217;re expecting one file to be selected. <strong>Obj<\/strong> is the uasset to update.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b843467 elementor-widget elementor-widget-heading\" data-id=\"b843467\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">b. The Reimport function <\/h3>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-acb6031 elementor-widget elementor-widget-text-editor\" data-id=\"acb6031\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>The<strong> Obj*<\/strong> variable throughout these virtual functions is our uasset, the old one that we are trying to overwrite.\u00a0 Now, after SetReimportPaths function, unreal engine will call the Reimport function with the <strong>Obj<\/strong> that we just updated in SetReimportPaths(). The update we made in that object is that we updated the file paths variable; SourceBcgFile. We are going to use this new path in the Reimport function.<\/p><p>Specifically, we are going to call ImportObject with this new path that we got from SetReimportPaths.\u00a0<\/p><p>Unreal engine will then call FactoryCreateFile()&#8230;\u00a0 The overridden method we created in the initial tutorial create a custom asset tutorial. The import and reimport process is now complete.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7364dd7 elementor-widget elementor-widget-heading\" data-id=\"7364dd7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">The Reimport Button<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d975b1d elementor-widget elementor-widget-text-editor\" data-id=\"d975b1d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>There will be a reimport button when you double-click your asset and open its asset editor. You&#8217;ll find it on the top menu of the asset under the &#8220;Asset&#8221; submenu. We prefer our reimport button on the right-click menu but we don&#8217;t cover it in this tutorial. For that, you can read the <a href=\"https:\/\/store.algosyntax.com\/tutorials\/unreal-engine\/ue5-how-to-add-reimport-button-to-right-click-menu\/\">how-to add reimport button to the right-click menu of a custom asset tutorial.<\/a><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-64a20d7 elementor-widget elementor-widget-heading\" data-id=\"64a20d7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Conclusion<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e5034fc elementor-widget elementor-widget-text-editor\" data-id=\"e5034fc\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>If you have questions and comments feel free to email us. We hope you check out our Plugin Development Course for unreal engine first though, whatever we may have skipped in these tutorials, it&#8217;s definitely covered in the video in the course.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"featured_media":0,"template":"","asx-lms-tutorial-categories":[55,58,45],"asx-lms-tutorial-tags":[46],"class_list":["post-3448","asx-lms-tutorial-cpt","type-asx-lms-tutorial-cpt","status-publish","hentry","asx-lms-tutorial-categories-plugin-development","asx-lms-tutorial-categories-unreal-c-api","asx-lms-tutorial-categories-unreal-engine","asx-lms-tutorial-tags-cpp","entry"],"acf":[],"_links":{"self":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/3448","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt"}],"about":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/types\/asx-lms-tutorial-cpt"}],"version-history":[{"count":0,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/3448\/revisions"}],"wp:attachment":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/media?parent=3448"}],"wp:term":[{"taxonomy":"asx-lms-tutorial-categories","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-categories?post=3448"},{"taxonomy":"asx-lms-tutorial-tags","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-tags?post=3448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}