UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InterchangeManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include <atomic>
6
7#include "CoreMinimal.h"
8
10#include "Containers/Queue.h"
12#include "HAL/CriticalSection.h"
13#include "HAL/Thread.h"
14#include "HAL/ThreadSafeBool.h"
25#include "Templates/Tuple.h"
26#include "UObject/GCObject.h"
27#include "UObject/Package.h"
28#include "UObject/Object.h"
31#include "Containers/Ticker.h"
32
33#include "InterchangeManager.generated.h"
34
40class ULevel;
41
42namespace UE::Interchange
43{
44 struct FAnalyticsHelper;
45}
46
50
53
58
60{
61 None = 0x00,
62 Name = 0x01,
63 ObjectName = 0x02,
64 ObjectPath = 0x04,
65 LongPackage = 0x08
66};
68
69//Thread safe delegate since this can be broadcast in any thread
70DECLARE_TS_MULTICAST_DELEGATE_TwoParams(FOnSanitizeName, FString& /*NameToSanitize*/, const ESanitizeNameTypeFlags /*TypeName*/);
71
72namespace UE
73{
74 namespace Interchange
75 {
77 {
78 public:
81 private:
82 bool bOriginalInterchangeImportEnableState;
83 };
84
86 {
87 public:
88 INTERCHANGEENGINE_API explicit FScopedSourceData(const FString& Filename);
90 INTERCHANGEENGINE_API UInterchangeSourceData* GetSourceData() const;
91 private:
92 TStrongObjectPtr<UInterchangeSourceData> SourceDataPtr = nullptr;
93 };
94
96 {
97 public:
101
102 private:
103 TStrongObjectPtr<UInterchangeTranslatorBase> ScopedTranslatorPtr = nullptr;
104 };
105
116
117 enum class EImportType : uint8
118 {
122 };
123
125 {
126 // True if the import process is unattended. We cannot show UI if the import is automated.
127 bool bIsAutomated = false;
128
129 // True if redirectors will be followed when determining what location to import an asset.
130 bool bFollowRedirectors = false;
131
132 // We can import assets or full scene.
133 EImportType ImportType = EImportType::ImportType_None;
134
135 // True if we are reimporting assets or a scene.
136 UObject* ReimportObject = nullptr;
137
138 // Level to import into, if we are doing a scene import.
139 ULevel* ImportLevel = nullptr;
140
143
145 bool bReplaceExisting = true;
146 };
147
148 class FImportResult : protected FGCObject
149 {
150 public:
152
155
156 FImportResult(const FImportResult&) = delete;
158
159 virtual ~FImportResult() = default;
160
161 public:
162 enum class EStatus
163 {
164 Invalid,
166 Done
167 };
168
169 INTERCHANGEENGINE_API EStatus GetStatus() const;
170
171 INTERCHANGEENGINE_API bool IsValid() const;
172
173 INTERCHANGEENGINE_API void SetInProgress();
174 INTERCHANGEENGINE_API void SetDone();
175 INTERCHANGEENGINE_API void WaitUntilDone(bool bSynchronous = false);
176
177 // Assets are only made available once they have been completely imported (passed through the entire import pipeline).
178 // While the status isn't EStatus::Done, the list can grow between subsequent calls.
179 // FAssetImportResult holds a reference to the assets so that they aren't garbage collected.
180 INTERCHANGEENGINE_API const TArray< UObject* >& GetImportedObjects() const;
181
182 // Helper to get the first asset of a certain class. Use when expecting a single asset of that class to be imported, because the order isn't deterministic.
183 INTERCHANGEENGINE_API UObject* GetFirstAssetOfClass(UClass* InClass) const;
184
185 // Return the results of this asset import operation.
186 UInterchangeResultsContainer* GetResults() const { return Results; }
187
188 // Adds an asset to the list of imported assets.
189 INTERCHANGEENGINE_API void AddImportedObject(UObject* ImportedObject);
190
191 // Callback when the status switches to done.
192 INTERCHANGEENGINE_API void OnDone(TFunction< void(FImportResult&) > Callback);
193
194 //Set the async helper that own this import result
196
197 // Internal delegates. To set these, use the FImportAssetParameters when calling the Interchange import functions.
200
203
204 protected:
205 /* FGCObject interface */
206 INTERCHANGEENGINE_API virtual void AddReferencedObjects(FReferenceCollector& Collector) override;
207 virtual FString GetReferencerName() const override
208 {
209 return TEXT("UE::Interchange::FImportResult");
210 }
211
212 private:
213 std::atomic< EStatus > ImportStatus;
214
215 TArray< TObjectPtr<UObject> > ImportedObjects;
216 mutable FRWLock ImportedObjectsRWLock;
218
219 TWeakPtr<class FImportAsyncHelper> AsyncHelper = nullptr;
220
221 TFunction< void(FImportResult&) > DoneCallback;
222 };
223
224 using FAssetImportResultRef = TSharedRef< FImportResult, ESPMode::ThreadSafe >;
225 using FSceneImportResultRef = TSharedRef< FImportResult, ESPMode::ThreadSafe >;
228
230 {
231 public:
233
235
236 /* FGCObject interface */
237 virtual void AddReferencedObjects(FReferenceCollector& Collector) override;
238 virtual FString GetReferencerName() const override
239 {
240 return TEXT("UE::Interchange::FImportAsyncHelper");
241 }
242
243 bool bRunSynchronous = false;
244 bool bRuntimeOrPIE = false;
245
248
249 //The base path to import the content.
251
252 //The following arrays are per source data
256
257 //The pipelines array is not per source data.
259 //The original pipelines asset to save in the asset reimport data. The original pipeline can restore Python class member value.
260 //Python class instanced assets cannot be saved, so we have to serialize in JSON the data to restore it when we do a reimport.
262
273
276
277 //Return true if we can import this class, or false otherwise.
278 bool IsClassImportAllowed(UClass* Class);
279
280 UPackage* GetCreatedPackage(const FString& PackageName) const;
281 void AddCreatedPackage(const FString& PackageName, UPackage* Package);
282
283 UInterchangeFactoryBase* GetCreatedFactory(const FString& FactoryNodeUniqueId) const;
284 void AddCreatedFactory(const FString& FactoryNodeUniqueId, UInterchangeFactoryBase* Factory);
285
287 {
288 FSoftObjectPath ImportedObject; // The object that was imported.
289 UInterchangeFactoryBase* Factory = nullptr; //The factory that created the imported object.
290 UInterchangeFactoryBaseNode* FactoryNode = nullptr; //The node that describes the object.
292 mutable bool bPostEditChangeCalled = false; //This field is set by the PreCompletionTask and need to be mutable
293 };
294
295 INTERCHANGEENGINE_API FImportedObjectInfo& AddDefaultImportedAssetGetRef(int32 SourceIndex);
296 const FImportedObjectInfo* FindImportedAssets(int32 SourceIndex, TFunction< bool(const FImportedObjectInfo& ImportedObjects) > Predicate) const;
297 void IterateImportedAssets(int32 SourceIndex, TFunction< void(const TArray<FImportedObjectInfo>& ImportedObjects) > Callback) const;
298 void IterateImportedAssetsPerSourceIndex(TFunction< void(int32 SourceIndex, const TArray<FImportedObjectInfo>& ImportedObjects) > Callback) const;
299
300 FImportedObjectInfo& AddDefaultImportedSceneObjectGetRef(int32 SourceIndex);
301 const FImportedObjectInfo* FindImportedSceneObjects(int32 SourceIndex, TFunction< bool(const FImportedObjectInfo& ImportedObjects) > Predicate) const;
302 void IterateImportedSceneObjects(int32 SourceIndex, TFunction< void(const TArray<FImportedObjectInfo>& ImportedObjects) > Callback) const;
303 void IterateImportedSceneObjectsPerSourceIndex(TFunction< void(int32 SourceIndex, const TArray<FImportedObjectInfo>& ImportedObjects) > Callback) const;
304
305 /*
306 * Return true if the Object is imported by this async import, or false otherwise.
307 */
308 bool IsImportingObject(UObject* Object) const;
309
311
314
315 //If we cancel the tasks, we set this Boolean to true.
316 std::atomic<bool> bCancel;
317
318 void SendAnalyticImportEndData();
319 void ReleaseTranslatorsSource();
320
324 TArray<uint64> GetCompletionTaskGraphEvent();
325
326 void InitCancel();
327
328 void CleanUp();
329
331
332 private:
333 FCriticalSection ClassPermissionLock;
334 // Set of classes whose creation has been denied.
335 TSet<UClass*> DeniedClasses;
336 // Set of classes whose creation is allowed.
337 TSet<UClass*> AllowedClasses;
338
339 //Created package map. The key is the package name. We cannot create packages asynchronously, so we have to create a game thread task to do this.
340 mutable FCriticalSection CreatedPackagesLock;
341 TMap<FString, UPackage*> CreatedPackages;
342
343 // Created factories map. The key is the factory node UID.
344 mutable FCriticalSection CreatedFactoriesLock;
346
347 mutable FCriticalSection ImportedAssetsPerSourceIndexLock;
348 TMap<int32, TArray<FImportedObjectInfo>> ImportedAssetsPerSourceIndex;
349
350 mutable FCriticalSection ImportedSceneObjectsPerSourceIndexLock;
351 TMap<int32, TArray<FImportedObjectInfo>> ImportedSceneObjectsPerSourceIndex;
352 };
353
354 /* This function takes an asset that represents a pipeline and generates a UInterchangePipelineBase asset. */
356 } //ns Interchange
357} //ns UE
358
362UCLASS(Transient, BlueprintType, MinimalAPI)
364{
366public:
367
368 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
369 TArray<FSoftObjectPath> OverridePipelines;
370
371 UFUNCTION(BlueprintCallable, Category = "Interchange | PipelineStackOverride")
372 INTERCHANGEENGINE_API void AddPythonPipeline(UInterchangePythonPipelineBase* PipelineBase);
373
374 UFUNCTION(BlueprintCallable, Category = "Interchange | PipelineStackOverride")
375 INTERCHANGEENGINE_API void AddBlueprintPipeline(UInterchangeBlueprintPipelineBase* PipelineBase);
376
377 UFUNCTION(BlueprintCallable, Category = "Interchange | PipelineStackOverride")
378 INTERCHANGEENGINE_API void AddPipeline(UInterchangePipelineBase* PipelineBase);
379};
380
381USTRUCT(BlueprintType)
383{
385
386 // If the import is a reimport for a specific asset, set the asset to reimport here.
387 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
388 TObjectPtr<UObject> ReimportAsset = nullptr;
389
390 // If we are doing a reimport, set the source index here. Some assets have more then one source file that each contains part of the asset content.
391 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
392 int32 ReimportSourceIndex = INDEX_NONE;
393
394 // Tell Interchange that import is automated and it shouldn't present a modal window.
395 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
396 bool bIsAutomated = false;
397
398 // Tell Interchange to follow redirectors when determining the location an asset will be imported.
399 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
400 bool bFollowRedirectors = false;
401
402 // Adding overrides tells Interchange to use the specific custom set of pipelines instead of letting the user or the system choose.
403 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset", meta = (AllowedClasses = "/Script/InterchangeCore.InterchangePipelineBase, /Script/InterchangeEngine.InterchangeBlueprintPipelineBase, /Script/InterchangeEngine.InterchangePythonPipelineAsset"))
404 TArray<FSoftObjectPath> OverridePipelines;
405
406 //Level to import into when doing a scene import.
407 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
408 TObjectPtr<ULevel> ImportLevel = nullptr;
409
411 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
412 FString DestinationName;
413
415 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
416 bool bReplaceExisting = true;
417
419 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset")
420 bool bForceShowDialog = false;
421
422 /* Delegates used to track the imported objects. */
423
424 // This is called each time an asset is imported or reimported from the import call.
425 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset", meta=(PinHiddenByDefault))
427 FOnObjectImportDoneNative OnAssetDoneNative;
428
429 // This is called when all the assets were imported from the source data.
430 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset", meta=(PinHiddenByDefault))
431 FOnImportDoneDynamic OnAssetsImportDone;
432 FOnImportDoneNative OnAssetsImportDoneNative;
433
434 // This is called each time an object in the scene is imported or reimported from the import call.
435 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset", meta=(PinHiddenByDefault))
436 FOnObjectImportDoneDynamic OnSceneObjectDone;
437 FOnObjectImportDoneNative OnSceneObjectDoneNative;
438
439 // This is called when all the scene objects were imported from the source data.
440 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange|ImportAsset", meta=(PinHiddenByDefault))
441 FOnImportDoneDynamic OnSceneImportDone;
442 FOnImportDoneNative OnSceneImportDoneNative;
443
444 // Tell Interchange that import must run synchronously on the game thread.
445 //This is an internal property set by the Import API
446 mutable bool bRunSynchronous;
447};
448
449UCLASS(Transient, BlueprintType, CustomConstructor, MinimalAPI)
451{
453public:
454
456
462 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
463 static UInterchangeManager* GetInterchangeManagerScripted()
464 {
465 return &GetInterchangeManager();
466 }
467
469 static INTERCHANGEENGINE_API UInterchangeManager& GetInterchangeManager();
470
472 static INTERCHANGEENGINE_API bool IsInterchangeImportEnabled();
474 static INTERCHANGEENGINE_API void SetInterchangeImportEnabled(bool bEnabled);
475
477 static INTERCHANGEENGINE_API bool IsImporting();
478
485
486 // Delegates used to register and unregister.
487
491 //Fires when the first import process starts.
493 //Fires when the last import process finishes.
495
496 //Fire when we need to sanitize a name, make sure your delegate code is thread safe, since it will be broadcast in any thread.
498
499 // Called when before the application is exiting.
501
502 INTERCHANGEENGINE_API void SanitizeNameInline(FString& NameToSanitize, const ESanitizeNameTypeFlags NameType);
511 INTERCHANGEENGINE_API bool RegisterTranslator(const UClass* TranslatorClass);
512
520 INTERCHANGEENGINE_API bool RegisterFactory(const UClass* Factory);
521
529 INTERCHANGEENGINE_API bool RegisterWriter(const UClass* Writer);
530
538 INTERCHANGEENGINE_API bool RegisterImportDataConverter(const UClass* Converter);
539
546 INTERCHANGEENGINE_API bool ConvertImportData(UObject* Asset, const FString& Extension) const;
547
555
564
568 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
569 INTERCHANGEENGINE_API TArray<FString> GetSupportedFormats(const EInterchangeTranslatorType ForTranslatorType) const;
570
574 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
576
581 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
582 INTERCHANGEENGINE_API TArray<FString> GetSupportedFormatsForObject(const UObject* Object, int32 SourceFileIndex) const;
583
592 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
593 INTERCHANGEENGINE_API bool CanTranslateSourceData(const UInterchangeSourceData* SourceData, bool bSceneImportOnly = false) const;
594
600 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
601 INTERCHANGEENGINE_API bool CanReimport(const UObject* Object, TArray<FString>& OutFilenames) const;
602
614 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
616
627 INTERCHANGEENGINE_API bool ImportAsset(const FString& ContentPath, const UInterchangeSourceData* SourceData, const FImportAssetParameters& ImportAssetParameters);
628
638 INTERCHANGEENGINE_API UE::Interchange::FAssetImportResultRef ImportAssetWithResult(const FString& ContentPath, const UInterchangeSourceData* SourceData, const FImportAssetParameters& ImportAssetParameters);
639
649 INTERCHANGEENGINE_API UE::Interchange::FAssetImportResultRef ImportAssetAsync(const FString& ContentPath, const UInterchangeSourceData* SourceData, const FImportAssetParameters& ImportAssetParameters);
650
660 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
661 INTERCHANGEENGINE_API bool ScriptedImportAssetAsync(const FString& ContentPath, const UInterchangeSourceData* SourceData, const FImportAssetParameters& ImportAssetParameters);
662
677 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
679
689 INTERCHANGEENGINE_API UE::Interchange::FAssetImportResultRef ReimportAssetAsync(UObject* ObjectToReimport, const FImportAssetParameters& ImportAssetParameters);
690
705 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
707
719 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
720 INTERCHANGEENGINE_API bool ImportScene(const FString& ContentPath, const UInterchangeSourceData* SourceData, const FImportAssetParameters& ImportAssetParameters);
721
731 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
732 INTERCHANGEENGINE_API bool ScriptedImportSceneAsync(const FString& ContentPath, const UInterchangeSourceData* SourceData, const FImportAssetParameters& ImportAssetParameters);
733
743 INTERCHANGEENGINE_API TTuple<UE::Interchange::FAssetImportResultRef, UE::Interchange::FSceneImportResultRef>
744 ImportSceneAsync(const FString& ContentPath, const UInterchangeSourceData* SourceData, const FImportAssetParameters& ImportAssetParameters);
745
753 UFUNCTION(BlueprintCallable, Category = "Interchange | Export Manager")
754 INTERCHANGEENGINE_API bool ExportAsset(const UObject* Asset, bool bIsAutomated = false);
755
762 UFUNCTION(BlueprintCallable, Category = "Interchange | Export Manager")
763 INTERCHANGEENGINE_API bool ExportScene(const UObject* World, bool bIsAutomated = false);
764
765 /*
766 * Script helper to create a source data object that points to a file on disk.
767 * @Param InFilename: Specify a file on disk.
768 * @return: A new UInterchangeSourceData.
769 */
770 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
771 static INTERCHANGEENGINE_API UInterchangeSourceData* CreateSourceData(const FString& InFileName);
772
778 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
779 INTERCHANGEENGINE_API const UClass* GetRegisteredFactoryClass(const UClass* ClassToMake) const;
780
785 INTERCHANGEENGINE_API TSharedRef<UE::Interchange::FImportAsyncHelper, ESPMode::ThreadSafe> CreateAsyncHelper(const UE::Interchange::FImportAsyncHelperData& Data, const FImportAssetParameters& ImportAssetParameters);
786
788 INTERCHANGEENGINE_API void ReleaseAsyncHelper(TWeakPtr<UE::Interchange::FImportAsyncHelper, ESPMode::ThreadSafe> AsyncHelper);
789
794 INTERCHANGEENGINE_API TSharedPtr<UE::Interchange::FImportAsyncHelper, ESPMode::ThreadSafe> GetAsyncHelper(int32 UniqueId);
795
796 /*
797 * Return the first translator that can translate the source data.
798 * @Param SourceData - The source data that you want a translator for.
799 * @return return a matching translator, or nullptr if no translators exist for the source data.
800 */
801 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
802 INTERCHANGEENGINE_API UInterchangeTranslatorBase* GetTranslatorForSourceData(const UInterchangeSourceData* SourceData) const;
803
807 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
808 INTERCHANGEENGINE_API bool IsInterchangeActive();
809
815 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
816 INTERCHANGEENGINE_API bool WarnIfInterchangeIsActive();
817
821 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
823
829 INTERCHANGEENGINE_API bool CanTranslateSourceDataWithPayloadInterface(const UInterchangeSourceData* SourceData, const UClass* PayloadInterfaceClass) const;
830
831 /*
832 * Return the first translator that can translate the source data with the specified PayloadInterface.
833 * @Param SourceData - The source data that you want a translator for.
834 * @Param PayloadInterfaceClass - The PayloadInterface that the translator must implement.
835 * @return return a matching translator that implements the specified PayloadInterface, or nullptr if none exists.
836 */
837 INTERCHANGEENGINE_API UInterchangeTranslatorBase* GetTranslatorSupportingPayloadInterfaceForSourceData(const UInterchangeSourceData* SourceData, const UClass* PayloadInterfaceClass) const;
838
843 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
844 INTERCHANGEENGINE_API bool IsObjectBeingImported(UObject* Object) const;
845
852
853
858 INTERCHANGEENGINE_API static void SetReplaceExistingAlldialogAnswer(bool bReplaceExistingAllDialogAnswer);
859
863 INTERCHANGEENGINE_API static void ResetReplaceExistingAlldialogAnswerSet();
864
868 INTERCHANGEENGINE_API static TOptional<bool> GetReplaceExistingAlldialogAnswer();
869
873 INTERCHANGEENGINE_API void SetEditorUtilities(UClass* EditorUtilitiesClass);
874
878 INTERCHANGEENGINE_API UInterchangeEditorUtilitiesBase* GetEditorUtilities() const;
879
883 INTERCHANGEENGINE_API bool CanUseTranslator(UInterchangeTranslatorBase* Translator) const;
884
886
888 static INTERCHANGEENGINE_API bool IsAttended();
889
890 /*
891 * Find all pipeline candidates (C++, Blueprint, and Python).
892 * @Param SourceData - The source data you need a translator for.
893 * @return return a matching translator, or nullptr if there is no match.
894 */
895 INTERCHANGEENGINE_API void FindPipelineCandidate(TArray<UClass*>& PipelineCandidates);
896
902 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
903 INTERCHANGEENGINE_API void CancelAllTasks();
904
908 UFUNCTION(BlueprintCallable, Category = "Interchange | Import Manager")
909 INTERCHANGEENGINE_API void WaitUntilAllTasksDone(bool bCancel);
910
911
916 INTERCHANGEENGINE_API void SetActiveMode(bool IsActive);
917
922 INTERCHANGEENGINE_API void StartQueuedTasks(bool bCancelAllTasks = false);
923
927 INTERCHANGEENGINE_API TTuple<UE::Interchange::FAssetImportResultRef, UE::Interchange::FSceneImportResultRef>
928 ImportInternal(const FString& ContentPath, const UInterchangeSourceData* SourceData, const FImportAssetParameters& ImportAssetParameters, const UE::Interchange::EImportType ImportType);
929
930 TOptional<FString> ValidateReimportParameter(UObject* ObjectToReimport, const FImportAssetParameters& ImportAssetParameters, bool bRunSynchronous);
931
932 int32 GetImportTaskCount() const;
933 TSharedPtr<UE::Interchange::FImportAsyncHelper, ESPMode::ThreadSafe> GetImportTaskForIndex(int32 Index) const;
934 TSharedPtr<UE::Interchange::FImportAsyncHelper, ESPMode::ThreadSafe> GetImportTaskForAsyncHelperUniqueId(int32 AsyncHelperUniqueId) const;
935 /* Return the index in the ImportTasks array */
936 int32 AddImportTask(TSharedPtr<UE::Interchange::FImportAsyncHelper, ESPMode::ThreadSafe> ImportTask);
937 void RemoveImportTask(TSharedPtr<UE::Interchange::FImportAsyncHelper, ESPMode::ThreadSafe> ImportTask);
938 void RemoveImportTask(int32 AsyncHelperUniqueId);
939
940private:
941
942 static bool bIsCreatingSingleton;
943
944 struct FQueuedTaskData
945 {
947 UClass* TranslatorClass = nullptr;
948 };
949
950 TMap<UClass*, bool> NonParallelTranslatorLocks;
951 TMap<UClass*, TArray<FQueuedTaskData>> NonParallelTranslatorQueueTasks;
952
953 //Queue all incoming tasks if there are more started task then we have cores.
954 TQueue<FQueuedTaskData> QueuedTasks;
955 int32 QueueTaskCount = 0;
956
957 //Queue all incoming tasks that are not directly import or re-import of assets.
958 // The post import tasks are executed only when all the QueuedTasks are completed and empty.
959 //Those tasks can start an import task (QueuedTasks), one example is the skeletal mesh alternate skinning which requires to import several files for each profile.
961
962 //Ticker which is on only if we have some QueuedPostImportTasks
963 FTSTicker::FDelegateHandle QueuedPostImportTasksTickerHandle;
964
966 mutable FCriticalSection ImportTasksLock;
967 //By using pointer, there is no issue if the array get resized.
968 UE_DEPRECATED(5.6, "Use the provided API to manipulate the Import tasks array. This array need to be thread safe")
969 TArray<TSharedPtr<UE::Interchange::FImportAsyncHelper, ESPMode::ThreadSafe> > ImportTasks;
970
972 FTSTicker::FDelegateHandle NotificationTickHandle;
973
974 // Caching the registered translator classes to avoid double registration.
975 UPROPERTY()
976 TSet<TObjectPtr<const UClass>> RegisteredTranslatorsClass;
977
978 //The manager will create translator at every import, translator must be able to retrieve payload information when the factory ask for it.
979 //The translator stored has value is only use to know if we can use this type of translator.
980// UPROPERTY()
981// TArray<TObjectPtr<UInterchangeTranslatorBase>> RegisteredTranslators;
982
983 //The manager will create only one pipeline per type
984// UPROPERTY()
985// TMap<TObjectPtr<const UClass>, TObjectPtr<UInterchangePipelineBase> > RegisteredPipelines;
986
987 //The manager will create only one factory per type.
988 UPROPERTY()
989 TMap<TObjectPtr<const UClass>, TObjectPtr<const UClass> > RegisteredFactoryClasses;
990
991 //The manager will create only one writer per type.
992 UPROPERTY()
993 TMap<TObjectPtr<const UClass>, TObjectPtr<UInterchangeWriterBase> > RegisteredWriters;
994
995 //The manager will create only one converter per type.
996 UPROPERTY()
998
999 //We support one editor utilities class
1000 TStrongObjectPtr<UInterchangeEditorUtilitiesBase> EditorUtilities = nullptr;
1001
1002 //If interchange is currently importing, we have a timer to watch the cancel and we block GC.
1003 FThreadSafeBool bIsActive = false;
1004
1005 //If the user wants to use the same import pipeline stack for all queued tasks.
1006 //This map is reset when the ImportTasks array is empty.
1007 TMap<UClass*, TArray<UInterchangePipelineBase*>> ImportAllWithSamePipelines;
1008
1009 //Indicates that the import process was canceled by the user.
1010 //This Boolean is reset to false when the ImportTasks array is empty.
1011 bool bImportCanceled = false;
1012
1013 //We want to avoid starting an import task during a GC.
1014 FDelegateHandle GCEndDelegate;
1015 FDelegateHandle GCPreDelegate;
1016 bool bGCEndDelegateCancellAllTask = false;
1017
1018 friend class UE::Interchange::FScopedTranslator;
1019 // #todo_interchange: Remove when Interchange utility method for pipelines is done
1021};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:48
#define DECLARE_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:23
#define DECLARE_DYNAMIC_DELEGATE_OneParam(DelegateName, Param1Type, Param1Name)
Definition DelegateCombinations.h:52
#define DECLARE_TS_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:59
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
return true
Definition ExternalRpcRegistry.cpp:601
ESanitizeNameTypeFlags
Definition InterchangeManager.h:60
EInterchangeTranslatorType
Definition InterchangeTranslatorBase.h:46
EInterchangeTranslatorAssetType
Definition InterchangeTranslatorBase.h:55
#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 USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
ESPMode
Definition SharedPointerFwd.h:12
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition AsyncTaskNotification.h:114
Definition IDelegateInstance.h:14
Definition GCObject.h:128
Definition InterchangeFactoryBase.h:41
Definition UObjectGlobals.h:1292
Definition UObjectGlobals.h:2492
Definition Ticker.h:27
Definition ThreadSafeBool.h:17
Definition InterchangeCore.Build.cs:6
Definition InterchangeEngine.Build.cs:6
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition Queue.h:48
Definition SharedPointer.h:692
Definition StrongObjectPtrTemplates.h:26
Definition SharedPointer.h:1295
Definition Class.h:3793
Definition CriticalSection.h:14
Definition InterchangeManager.h:230
TArray< TObjectPtr< UInterchangePipelineBase > > Pipelines
Definition InterchangeManager.h:258
FSceneImportResultRef SceneImportResult
Definition InterchangeManager.h:313
TArray< TObjectPtr< UInterchangeSourceData > > SourceDatas
Definition InterchangeManager.h:254
TArray< uint64 > TranslatorTasks
Definition InterchangeManager.h:263
TArray< TObjectPtr< UInterchangeTranslatorBase > > Translators
Definition InterchangeManager.h:255
TArray< uint64 > SceneTasks
Definition InterchangeManager.h:272
FImportAsyncHelperData TaskData
Definition InterchangeManager.h:310
FString ContentBasePath
Definition InterchangeManager.h:250
TArray< uint64 > FinalizeImportObjectTasks
Definition InterchangeManager.h:271
virtual FString GetReferencerName() const override
Definition InterchangeManager.h:238
TArray< uint64 > PipelineTasks
Definition InterchangeManager.h:264
TArray< UObject * > OriginalPipelines
Definition InterchangeManager.h:261
std::atomic< bool > bCancel
Definition InterchangeManager.h:316
TArray< uint64 > WaitAssetCompilationTasks
Definition InterchangeManager.h:265
TArray< uint64 > ImportObjectQueryPayloadsTasks
Definition InterchangeManager.h:268
uint64 CompletionTask
Definition InterchangeManager.h:275
double TaskExecuteStarted
Definition InterchangeManager.h:330
uint64 PreCompletionTask
Definition InterchangeManager.h:274
int32 UniqueId
Definition InterchangeManager.h:247
uint64 ParsingTask
Definition InterchangeManager.h:267
FAssetImportResultRef AssetImportResult
Definition InterchangeManager.h:312
TArray< uint64 > ImportObjectTasks
Definition InterchangeManager.h:270
TArray< TStrongObjectPtr< UInterchangeBaseNodeContainer > > BaseNodeContainers
Definition InterchangeManager.h:253
TArray< uint64 > BeginImportObjectTasks
Definition InterchangeManager.h:269
TArray< uint64 > PostImportTasks
Definition InterchangeManager.h:266
Definition InterchangeManager.h:149
FOnObjectImportDoneDynamic OnObjectDone
Definition InterchangeManager.h:198
FImportResult & operator=(const FImportResult &)=delete
FOnImportDoneDynamic OnImportDone
Definition InterchangeManager.h:201
FOnObjectImportDoneNative OnObjectDoneNative
Definition InterchangeManager.h:199
FOnImportDoneNative OnImportDoneNative
Definition InterchangeManager.h:202
virtual ~FImportResult()=default
UInterchangeResultsContainer * GetResults() const
Definition InterchangeManager.h:186
virtual FString GetReferencerName() const override
Definition InterchangeManager.h:207
FImportResult(FImportResult &&)=delete
EStatus
Definition InterchangeManager.h:163
FImportResult(const FImportResult &)=delete
FImportResult & operator=(FImportResult &&)=delete
Definition InterchangeManager.h:107
Definition InterchangeManager.h:86
Definition InterchangeManager.h:96
Definition InterchangeAssetImportData.h:214
Definition InterchangeAssetImportData.h:21
Definition InterchangeBaseNodeContainer.h:39
Definition InterchangeBlueprintPipelineBase.h:15
Definition InterchangeEditorUtilitiesBase.h:12
Definition InterchangeFactoryBaseNode.h:188
Definition InterchangeFactoryBase.h:68
Definition InterchangeManager.h:451
DECLARE_MULTICAST_DELEGATE_OneParam(FInterchangeOnAssetPostReimport, UObject *)
FOnImportStarted OnImportStarted
Definition InterchangeManager.h:492
DECLARE_MULTICAST_DELEGATE_OneParam(FInterchangeOnBatchImportComplete, TStrongObjectPtr< UInterchangeResultsContainer >)
FInterchangeOnAssetPostImport OnAssetPostImport
Definition InterchangeManager.h:488
FSimpleMulticastDelegate OnPreDestroyInterchangeManager
Definition InterchangeManager.h:500
FOnImportFinished OnImportFinished
Definition InterchangeManager.h:494
DECLARE_MULTICAST_DELEGATE_OneParam(FInterchangeOnAssetPostImport, UObject *)
FInterchangeOnBatchImportComplete OnBatchImportComplete
Definition InterchangeManager.h:490
FInterchangeOnAssetPostReimport OnAssetPostReimport
Definition InterchangeManager.h:489
FOnSanitizeName OnSanitizeName
Definition InterchangeManager.h:497
Definition InterchangePipelineBase.h:217
Definition InterchangeManager.h:364
Definition InterchangePythonPipelineBase.h:18
Definition InterchangeResultsContainer.h:21
Definition InterchangeSourceData.h:23
Definition InterchangeTranslatorBase.h:68
Definition InterchangeWriterBase.h:14
Definition Level.h:423
Definition Object.h:95
Definition Package.h:216
Definition InterchangeHelper.cpp:9
INTERCHANGEENGINE_API UInterchangePipelineBase * GeneratePipelineInstance(const FSoftObjectPath &PipelineInstance)
Definition InterchangeManager.cpp:958
EImportType
Definition InterchangeManager.h:118
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition InterchangeManager.h:383
Definition SoftObjectPath.h:56
Definition ObjectPtr.h:488
Definition Optional.h:131
Definition Tuple.h:652
Definition InterchangeManager.h:125
FString DestinationName
Definition InterchangeManager.h:142
bool bIsReimport
Definition InterchangeManager.h:291
FSoftObjectPath ImportedObject
Definition InterchangeManager.h:288