Skip to content

Importers

Create Importer

Warning

All this code needs to be added to an editor module, or you could face compilation issues during shipping.

  1. The first thing is to define a UStruct to carry all the parameters you need for each Data Table to be imported.

    USTRUCT()
    struct FMyImporterSettings {
        GENERATED_BODY()
    public:
        UPROPERTY(EditAnywhere)
        FString Parameter;
    };
    

  2. Then you have to create a child class from UAbstractImporter and override Execute_Implementation to implement the main logic of the importer.

    UCLASS()
    class UMyImporter : public UAbstractImporter {
        GENERATED_BODY()
    
    public:
        UMyImporter();
    
        virtual void Execute() override;
    };
    

  3. Inside the Constructor, you have to set up a ParametersStruct (Any UStruct) and an optional importer name.

    UMyImporter::UMyImporter() {
        // Struct used to set up parameters for the import
        ParametersStruct = FMyImporterSettings::StaticStruct();
    
        // Importer name, used for the dialog
        ImporterName = LOCTEXT("MyImporter", "My Importer");
    }
    

  4. Inside the Execute, you have to implement the main logic of your importer.

    void UMyImporter::Execute() {
        FMyImporterSettings Parameters = GetSettings<FMyImporterSettings>();
    
        // Execute the main logic here
    }
    

  5. Get filled settings through the import dialog using the GetSettings<>() function.

    FMyImporterSettings Parameters = GetSettings<FMyImporterSettings>();
    

  6. The Execute function has no return since the completion event could be executed in a different tick than the current one. In Execute, you can make HTTP calls and then return the positive or negative response via these two Delegates:

    SuccessDelegate.ExecuteIfBound(this, ResCsvString, AdditionalText);
    
    FailDelegate.ExecuteIfBound(this, ErrorCode, FailedReasonText);