Download

How to get reference to selected assets in content browser?

Hi all,
I want to get a reference to a selected asset in the Content Browser, not a selected actor in the World Outliner.
Is there a way to do that in Blueprints, or do I need to write a custom c++ function?

I need to mass-assign a material to selected Static Mesh Actors in the Content Browser, but the Bulk Property Matrix doesn’t have a Material setting, so I want to create a blutility that lets me do that.

Thanks in advance for your help!

You should be able to simply create a custom variable for your asset in the graph for your static meshes then simply use that variable where it’s needed.
Have you tried doing that?

Just to reiterate, this documentation should hopefully help you:
https://docs.unrealengine.com/latest/INT/Programming/Assets/ReferencingAssets/

Hey TrojanVirus,
thanks for the reply and suggestions.

I need to assign a material to all selected assets in the Content Browser, so creating a custom array variable isn’t ideal, as I would have to assign each asset I want to update 1 by 1 to the array. There is a Blueprint function called GetSelectionSet, which returns an array of all selected Actors in the Editor/World Outliner, but I need to return all selected Assets from the Content Browser instead.

Any other suggestions?

I don’t know of a specific node that does this. How many assets are we talking here? Sounds like a lot.

Here’s a thread that appears to be similar to what you’re trying to do:
https://answers.unrealengine.com/questions/285913/create-an-array-of-assets-from-folder.html

It looks like C++ is required.

Thanks for your help Trojan, I’m looking into the links you posted :slight_smile:

GEditor->GetSelectedObjects() I think.

This gives you all the selected assets:

    TArray<FAssetData> AssetDatas;
    FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
    IContentBrowserSingleton& ContentBrowserSingleton = ContentBrowserModule.Get();
    ContentBrowserSingleton.GetSelectedAssets(AssetDatas);

The problem with GEditor->GetSelectedObjects() is that it doesn’t include assets that haven’t been loaded yet, even if they are selected in the GUI.