Shorodei
(PrajwalManjunath)
April 14, 2015, 8:12pm
1
In my plugin, I need to find what asset is highlighted/selected in the content browser when the use presses my plugin’s button. I found this function:
GEditor->GetContentBrowserSelections(TArray<UClass*>&)
but this returns a list of classes instead of objects/files.
How do I get the asset file that is currently selected?
I have the same issue. Does anyone find a solution for something similar?
grizly32
(grizly32)
June 10, 2015, 6:38pm
3
It’s strange because the documentation for UEditorEngine::GetContentBrowserSelections shows the input parameter as being FAssetData not TArray
[link text][1]
[1]: UEditorEngine::GetContentBrowserSelections | Unreal Engine Documentation
The code however does indeed use TArray so you will only get classes back.
I wrote a quick method that gets the selected info but you will have to change these source code files:
EditorEngine.h:
/** Function to return list of assets currently selected in content browser (loaded/not loaded) */
void GetContentBrowserSelectedItems(TArray<FAssetData>& Selection) const;
Editor.cpp:
void UEditorEngine::GetContentBrowserSelectedItems(TArray<FAssetData>& Selection) const
{
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
TArray<FAssetData> SelectedAssets;
ContentBrowserModule.Get().GetSelectedAssets(SelectedAssets);
Selection = SelectedAssets;
}
There might be a better way but in the meantime I hope that helps!
-Tim