Linker error using UAutomatedAssetImportData

I’m attempting to support the user triggered re-import of assets for our character class. Our designers want to be able to make changes to the character’s animations in Spine, and quickly re-import the assets to see those changes. They can do so by going to the asset in the content browser and then re-importing it from the asset details screen, but this is cumbersome, especially as it generates a large number of pop-up confirmation menus.

My plan to do this was to add a function to the the character class that returned a UAutomatedAssetImportData pointer and then use Blueprints to call ImportAssetsAutomated and pass it the relevant data. I have encountered an issue where the linker seems to have difficulty locating the UAutomatedAssetImportData class despite the fact that I have included “AutomatedAssetImportData.h”

In my header file I have:

class UAutomatedAssetImportData;

UCLASS(config=Game)
class AOurCharacterClass: public APaperCharacter
{
    GENERATED_BODY()

    private:
    	UPROPERTY()
    	UAutomatedAssetImportData* _importData;
    public:
    	UFUNCTION(BlueprintCallable)
    	UAutomatedAssetImportData* GetAssetImportData();
}

Then in my .ccp I have:

#include "AutomatedAssetImportData.h"

    UAutomatedAssetImportData* AOurCharacterClass::GetAssetImportData()
    {
    	//if we don't have animation data to reimport, don't do ■■■■.
    	if (animationComponent == nullptr || animationComponent->SkeletonData == nullptr || animationComponent->Atlas == nullptr)
    	{
    		return nullptr;
    	}
    	
    	if (_importData == nullptr)
    	{
    		_importData = NewObject<UAutomatedAssetImportData>(this);
    	}
    
    	USpineSkeletonDataAsset* skel_data = animationComponent->SkeletonData;
    	USpineAtlasAsset* atlas_data = animationComponent->Atlas;
    
    	_importData->bReplaceExisting = true;
    	_importData->bSkipReadOnly = false;
    	_importData->DestinationPath = skel_data->GetPathName();
    	_importData->FactoryName = "USpineSkeletonAssetFactory";
    
    	TArray<FString>* filenames = &(_importData->Filenames);
    
    	if (filenames == nullptr)
    	{
    		//oh god, something's gone wrong
    		return nullptr;
    	}
    
    	filenames->Empty();
    	filenames->Add(skel_data->GetSkeletonDataFileName().ToString());
    	filenames->Add(atlas_data->GetAtlasFileName().ToString());
    
    	return _importData;
    }

But when I attempt to compile I get:

error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class UClass * __cdecl UAutomatedAssetImportData::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UAutomatedAssetImportData@@CAPEAVUClass@@XZ) referenced in function "class UAutomatedAssetImportData * __cdecl NewObject<class UAutomatedAssetImportData>(class UObject *)" (??$NewObject@VUAutomatedAssetImportData@@@@YAPEAVUAutomatedAssetImportData@@PEAVUObject@@@Z)

Any advice or assistance would be appreciated.

I did not try it, but my guess would be that you need to include the “UnrealEd” module into your Build.cs file. But as this is a editor-only module you need to follow these instructions for a successful compile process.

This solved my problem. I was not properly including the UnrealEd module. You will likely also want this link to the newer method for detecting if you’re running an editor build (as, perhaps obviously, you only want to link the UnrealEd module in editor builds).