How to use IAssetTools?

Hey folks, I am currently trying to use IAssetTools in C++. I have no problems using it in Blueprints but when it comes to c++ I am lost.
So why does this not work?

USelection* SelectedActors = GEditor->GetSelectedActors();
	TArray<UObject*> OutSelectedObjects;
	SelectedActors->GetSelectedObjects(AStaticMeshActor, OutSelectedObjects);

	IAssetTools* TGest = nullptr;
	TGest->ExportAssets(OutSelectedObjects, Path);

It is selecting the correct assets but crashes when trying to export them.

Run it in the debugger and then when it crashes take a look at the call stack etc to learn why its crashing.

Basically I already know that “= nullptr” causes the problem. I dont know what to place instead of it though. It needs something to intialize, else I get an compiler error

When you need to find things like that, a good way is to search the Engine/Editor source code.

Searching for “IAssetTools” in the entire source code gives bits like this:

	IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
1 Like

Ohh, nice tipp. I will try it later and let you know if it worked :slight_smile:

1 Like