UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InterchangeFactoryBase.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
9#include "UObject/Class.h"
10#include "UObject/Object.h"
13
14#include "InterchangeFactoryBase.generated.h"
15
16class ULevel;
21
22UENUM(BlueprintType)
34
41{
42public:
43 virtual void Execute() {};
44};
45
66UCLASS(BlueprintType, Blueprintable, Abstract, MinimalAPI)
68{
70public:
71
75 UFUNCTION(BlueprintCallable, Category = "Interchange | Factory")
76 virtual UClass* GetFactoryClass() const
77 {
78 return nullptr;
79 }
80
84 UFUNCTION(BlueprintCallable, Category = "Interchange | Factory")
86
91 {
93 UObject* Parent = nullptr;
94
96 FString AssetName = FString();
97
99 UInterchangeFactoryBaseNode* AssetNode = nullptr;
100
102 const UInterchangeTranslatorBase* Translator = nullptr;
103
105 const UInterchangeSourceData* SourceData = nullptr;
106
108 const UInterchangeBaseNodeContainer* NodeContainer = nullptr;
109
114 UObject* ReimportObject = nullptr;
115 };
116
118 {
119 //If the factory sets this to true, the Interchange task import object should skip this asset.
120 //An asset can be skipped if it already exists and the factory isn't doing a reimport. For example, if we import a static mesh and we find an existing material.
121 //We don't want to override the material in this case because the UE material often contains content related to gameplay.
122 bool bIsFactorySkipAsset = false;
123 //Return the UObject imported or reimported by the factory, or leave it set to nullptr if there was an error.
124 UObject* ImportedObject = nullptr;
125 };
126
127 UE_DEPRECATED(5.3, "This function is replaced by BeginImportAsset_GameThread.")
128 virtual UObject* ImportAssetObject_GameThread(const FImportAssetObjectParams& Arguments)
129 {
130 return nullptr;
131 }
132
134 {
135 return;
136 }
137
155
156 UE_DEPRECATED(5.3, "This function is replaced by ImportAsset_Async.")
157 virtual UObject* ImportAssetObject_Async(const FImportAssetObjectParams& Arguments)
158 {
159 //By default simply return the UObject created by BeginImportAsset_GameThread that was store in the asset node.
160 FSoftObjectPath ReferenceObject;
161 if (Arguments.AssetNode && Arguments.AssetNode->GetCustomReferenceObject(ReferenceObject))
162 {
163 return ReferenceObject.TryLoad();
164 }
165 return nullptr;
166 }
167
183
192 {
194 //By default simply return the UObject created by BeginImportAssetObject_GameThread that was store in the asset node.
195 FSoftObjectPath ReferenceObject;
196 if (Arguments.AssetNode && Arguments.AssetNode->GetCustomReferenceObject(ReferenceObject))
197 {
198 ImportAssetResult.ImportedObject = ReferenceObject.TryLoad();
199 }
200 return ImportAssetResult;
201 }
202
207 {
209 ULevel* Level = nullptr;
210
212 FString ObjectName;
213
215 UInterchangeFactoryBaseNode* FactoryNode = nullptr;
216
218 const UInterchangeBaseNodeContainer* NodeContainer = nullptr;
219
221 const UInterchangeSourceData* SourceData = nullptr;
222
226 UObject* ReimportObject = nullptr;
227
231 const UInterchangeFactoryBaseNode* ReimportFactoryNode = nullptr;
232
237
241 bool bIsReimport = false;
242
243 /*
244 * This represent the async helper unique id in case a factory need to retrieve the asynchelper associate to the import task
245 *
246 * TODO create a base class for FAsyncHelper in Interchange/Core so we can reference it here instead of using the unique identifier.
247 * The asynchelper is currently declare in Interchange/Engine so we can't refer to it here.
248 */
249 int32 AsyncHelperUid = INDEX_NONE;
250 };
251
259 {
260 return nullptr;
261 }
262
264 virtual void Cancel() {}
265
270 {
272 const UInterchangeSourceData* SourceData = nullptr;
273 UInterchangeFactoryBaseNode* FactoryNode = nullptr;
274
275
277 UObject* ImportedObject = nullptr;
279 UInterchangeBaseNodeContainer* NodeContainer = nullptr;
283
284 bool bIsReimport = false;
285 };
286
287 /*
288 * Do any UObject setup required before the build and after all dependency UObjects have been imported.
289 * @note - This function is called when starting the pre-completion task (before asset build is called for the asset).
290 */
291 virtual void SetupObject_GameThread(const FSetupObjectParams& Arguments)
292 {
294 }
295
296 /*
297 * Build the asset if it can be built.
298 *
299 * @Param Arguments - The setup object data.
300 * @Param OutPostEditchangeCalled - Set it to true if your implementation has called PostEditChange. Set it to false, interchange will call PostEditChange at the end of the import.
301 * @note - This function is called when starting the pre-completion task.
302 * @note - The default implementation for asset that do not have any build step is to call PostEditChange and set OutPostEditchangeCalled to true.
303 */
305 {
307#if WITH_EDITOR
308 if (Arguments.ImportedObject)
309 {
310 Arguments.ImportedObject->PostEditChange();
312 }
313#endif //WITH_EDITOR
314 }
315
316 /*
317 * Do any final UObject setup after the asset is built
318 * @note - This function is called after asset is built in FTaskWaitAssetCompilation
319 */
320 virtual void FinalizeObject_GameThread(const FSetupObjectParams& Arguments)
321 {
323 }
324
329 UFUNCTION(BlueprintCallable, Category = "Interchange | Factory")
330 virtual bool GetSourceFilenames(const UObject* Object, TArray<FString>& OutSourceFilenames) const
331 {
332 return false;
333 }
334
338 UFUNCTION(BlueprintCallable, Category = "Interchange | Factory")
339 virtual bool SetSourceFilename(const UObject* Object, const FString& SourceFilename, int32 SourceIndex) const
340 {
341 return false;
342 }
343
347 virtual void BackupSourceData(const UObject* Object) const
348 {
349 }
350
354 virtual void ReinstateSourceData(const UObject* Object) const
355 {
356 }
357
361 virtual void ClearBackupSourceData(const UObject* Object) const
362 {
363 }
364
368 virtual bool SetReimportSourceIndex(const UObject* Object, int32 SourceIndex) const
369 {
370 return false;
371 }
372
376 template <typename T>
378 {
379 check(Results != nullptr);
380 T* Item = Results->Add<T>();
381 return Item;
382 }
383
384
386 {
387 check(Results != nullptr);
388 Results->Add(Item);
389 }
390
391
396
401 void PreResetObjectProperties(const UInterchangeBaseNodeContainer* BaseNodeContainer, UInterchangeFactoryBaseNode* FactoryNode, UObject* ImportedObject)
402 {
403 // Restore delegates and force make the re-import strategy to apply pipeline properties.
405
406 ExecutePreResetObjectProperties(BaseNodeContainer, FactoryNode, ImportedObject);
407 }
408
413 void ResetObjectProperties(const UInterchangeBaseNodeContainer* BaseNodeContainer, UInterchangeFactoryBaseNode* FactoryNode, UObject* ImportedObject)
414 {
415 // Force use of ApplyPipelineProperties Reimport Strategy to apply attributes through the attribute delegates.
418
419 ExecuteResetObjectProperties(BaseNodeContainer, FactoryNode, ImportedObject);
420
421 // Restore Previous State
423 }
424
429 void PostResetObjectProperties(const UInterchangeBaseNodeContainer* BaseNodeContainer, UInterchangeFactoryBaseNode* FactoryNode, UObject* ImportedObject)
430 {
431 ExecutePostResetObjectProperties(BaseNodeContainer, FactoryNode, ImportedObject);
433 }
434
441 virtual UObject* GetObjectToReimport(UObject* ReimportObject, const UInterchangeFactoryBaseNode& FactoryNode, const FString& PackageName, const FString& AssetName, const FString& SubPathString)
442 {
443 return ReimportObject;
444 }
445
446protected:
447
451 virtual void ExecutePreResetObjectProperties(const UInterchangeBaseNodeContainer* BaseNodeContainer, UInterchangeFactoryBaseNode* FactoryNode, UObject* ImportedObject)
452 {
453 }
454
459 virtual void ExecuteResetObjectProperties(const UInterchangeBaseNodeContainer* BaseNodeContainer, UInterchangeFactoryBaseNode* FactoryNode, UObject* ImportedObject)
460 {
461 FactoryNode->ApplyAllCustomAttributeToObject(ImportedObject);
462 }
463
467 virtual void ExecutePostResetObjectProperties(const UInterchangeBaseNodeContainer* BaseNodeContainer, UInterchangeFactoryBaseNode* FactoryNode, UObject* ImportedObject)
468 {
469 }
470
471public:
472 UPROPERTY()
474};
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
EReimportStrategyFlags
Definition InterchangeFactoryBaseNode.h:172
EInterchangeFactoryAssetType
Definition InterchangeFactoryBase.h:24
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
CORE_API bool IsInGameThread()
Definition ThreadingBase.cpp:185
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition InterchangeFactoryBase.h:41
virtual void Execute()
Definition InterchangeFactoryBase.h:43
Definition Array.h:670
Definition SharedPointer.h:692
Definition Class.h:3793
Definition InterchangeBaseNodeContainer.h:39
Definition InterchangeFactoryBaseNode.h:188
INTERCHANGECORE_API void RestoreAllCustomAttributeDelegates()
Definition InterchangeFactoryBaseNode.cpp:330
INTERCHANGECORE_API void ApplyAllCustomAttributeToObject(UObject *Object) const
Definition InterchangeFactoryBaseNode.cpp:294
INTERCHANGECORE_API bool GetCustomReferenceObject(FSoftObjectPath &AttributeValue) const
Definition InterchangeFactoryBaseNode.cpp:258
INTERCHANGECORE_API bool SetReimportStrategyFlags(const EReimportStrategyFlags &ReimportStrategyFlags)
Definition InterchangeFactoryBaseNode.cpp:164
INTERCHANGECORE_API EReimportStrategyFlags GetReimportStrategyFlags() const
Definition InterchangeFactoryBaseNode.cpp:156
INTERCHANGECORE_API void RemoveAllCustomAttributeDelegates()
Definition InterchangeFactoryBaseNode.cpp:350
Definition InterchangeFactoryBase.h:68
virtual UObject * ImportSceneObject_GameThread(const FImportSceneObjectsParams &Arguments)
Definition InterchangeFactoryBase.h:258
virtual void BackupSourceData(const UObject *Object) const
Definition InterchangeFactoryBase.h:347
virtual FImportAssetResult EndImportAsset_GameThread(const FImportAssetObjectParams &Arguments)
Definition InterchangeFactoryBase.h:191
virtual bool SetReimportSourceIndex(const UObject *Object, int32 SourceIndex) const
Definition InterchangeFactoryBase.h:368
virtual FImportAssetResult BeginImportAsset_GameThread(const FImportAssetObjectParams &Arguments)
Definition InterchangeFactoryBase.h:147
void AddMessage(UInterchangeResult *Item)
Definition InterchangeFactoryBase.h:385
void ResetObjectProperties(const UInterchangeBaseNodeContainer *BaseNodeContainer, UInterchangeFactoryBaseNode *FactoryNode, UObject *ImportedObject)
Definition InterchangeFactoryBase.h:413
virtual UObject * GetObjectToReimport(UObject *ReimportObject, const UInterchangeFactoryBaseNode &FactoryNode, const FString &PackageName, const FString &AssetName, const FString &SubPathString)
Definition InterchangeFactoryBase.h:441
virtual void ClearBackupSourceData(const UObject *Object) const
Definition InterchangeFactoryBase.h:361
virtual void FinalizeObject_GameThread(const FSetupObjectParams &Arguments)
Definition InterchangeFactoryBase.h:320
virtual void CreatePayloadTasks(const FImportAssetObjectParams &Arguments, bool bAsync, TArray< TSharedPtr< UE::Interchange::FInterchangeTaskBase > > &PayloadTasks)
Definition InterchangeFactoryBase.h:133
virtual void ExecutePostResetObjectProperties(const UInterchangeBaseNodeContainer *BaseNodeContainer, UInterchangeFactoryBaseNode *FactoryNode, UObject *ImportedObject)
Definition InterchangeFactoryBase.h:467
virtual void SetupObject_GameThread(const FSetupObjectParams &Arguments)
Definition InterchangeFactoryBase.h:291
void SetResultsContainer(UInterchangeResultsContainer *InResults)
Definition InterchangeFactoryBase.h:392
void PreResetObjectProperties(const UInterchangeBaseNodeContainer *BaseNodeContainer, UInterchangeFactoryBaseNode *FactoryNode, UObject *ImportedObject)
Definition InterchangeFactoryBase.h:401
virtual FImportAssetResult ImportAsset_Async(const FImportAssetObjectParams &Arguments)
Definition InterchangeFactoryBase.h:175
T * AddMessage()
Definition InterchangeFactoryBase.h:377
virtual void ReinstateSourceData(const UObject *Object) const
Definition InterchangeFactoryBase.h:354
virtual void BuildObject_GameThread(const FSetupObjectParams &Arguments, bool &OutPostEditchangeCalled)
Definition InterchangeFactoryBase.h:304
virtual void ExecutePreResetObjectProperties(const UInterchangeBaseNodeContainer *BaseNodeContainer, UInterchangeFactoryBaseNode *FactoryNode, UObject *ImportedObject)
Definition InterchangeFactoryBase.h:451
void PostResetObjectProperties(const UInterchangeBaseNodeContainer *BaseNodeContainer, UInterchangeFactoryBaseNode *FactoryNode, UObject *ImportedObject)
Definition InterchangeFactoryBase.h:429
virtual void Cancel()
Definition InterchangeFactoryBase.h:264
virtual void ExecuteResetObjectProperties(const UInterchangeBaseNodeContainer *BaseNodeContainer, UInterchangeFactoryBaseNode *FactoryNode, UObject *ImportedObject)
Definition InterchangeFactoryBase.h:459
Definition InterchangePipelineBase.h:217
Definition InterchangeResult.h:33
Definition InterchangeResultsContainer.h:21
Definition InterchangeSourceData.h:23
Definition InterchangeTranslatorBase.h:68
Definition Level.h:423
Definition Object.h:95
Definition SoftObjectPath.h:56
COREUOBJECT_API UObject * TryLoad(FUObjectSerializeContext *InLoadContext=nullptr) const
Definition SoftObjectPath.cpp:781
Definition ObjectPtr.h:488
Definition InterchangeFactoryBase.h:91
UInterchangeFactoryBaseNode * AssetNode
Definition InterchangeFactoryBase.h:99
Definition InterchangeFactoryBase.h:118
UObject * ImportedObject
Definition InterchangeFactoryBase.h:124
Definition InterchangeFactoryBase.h:207
FString ObjectName
Definition InterchangeFactoryBase.h:212
TArray< TObjectPtr< UObject > > ImportAssets
Definition InterchangeFactoryBase.h:236
Definition InterchangeFactoryBase.h:270
TArray< UObject * > OriginalPipelines
Definition InterchangeFactoryBase.h:281
TArray< UInterchangePipelineBase * > Pipelines
Definition InterchangeFactoryBase.h:280
UObject * ImportedObject
Definition InterchangeFactoryBase.h:277
FString NodeUniqueID
Definition InterchangeFactoryBase.h:278
UInterchangeTranslatorBase * Translator
Definition InterchangeFactoryBase.h:282