Asset registry, impossible to instanciate abstract class

Hello,

I’m trying to access AssetRegistry from C++ :

#include "UStanceManager.h"
#include "Engine/AssetManager.h"
#include "AssetRegistry/AssetRegistryModule.h"
#include "AssetRegistry/IAssetRegistry.h"
#include "../Utils/ULogger.h"

void UStanceManager::PlayExAnim()
{
    auto registryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(FName("AssetRegistry"));
    auto registry = registryModule.Get();
}

But I get the error :

error C2259: 'IAssetRegistry' : impossible to instanciate abstract class

I’m on unreal 5.3

Can you help me with this please ?

Classic ‘auto’ problem, the default for auto’s is to act as a value type. However in this case you can’t use a value type because you aren’t allowed to instantiate an IAssetRegistry.

If you look at the return value of both of those functions, you’ll see that they return Something& which means a reference. So if you change both autos to auto& you will be creating and initializing references. Which will mean you won’t try to instantiate a type that you’re not allowed to.

Yes, that was the problem. Sorry I’m not used to all C++ subtleties !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.