Is there a way to control the content browser from C++ code?

Specifically, what I want to do two things:

  1. open/select a specific content folder in the content browser using C++
  2. select specific assets using C++

Is there a way to do this?

Are you sure you wanted to answer my question? Because I don’t want to load anything, I just want to highlight it in the content browser.

Deleted answer… You have access to the source code, dig around for the slate stuff and find. If you have VAX, should make it easier to locate.

You can communicate with content browser, but not sure if you cna do what you asking as some of editor UI is design to react to user interaction the listing to code somewhere else.

Content browser is contained in it’s own module

via Get() function you can get this:

You can get main module class via ModuleManager

Here you can browse ContentBrowser module code, best way to learn how to do things in editor is to check how engine modules themselfs talk to them

https://github.com/EpicGames/UnrealEngine/tree/97c8d3ef55e869e17ef149903eae2a33101381c9/Engine/Source/Editor/ContentBrowser

You could try also searching other editor components that talk to content browser and see how they talk to it, thats pretty much only way to learn how to do editor code as there practicly 0 documentation for it, which is not suppriceing as it a lot more complex then gameplay code.

Also reminder, rememeber to filter the editor code in your module with #if WITH_EDITOR or make separate editor only module for it which is common practice in engine code it self. If you don’t do that you game or game that use you plugin if it’s a plug in won’t package

I just wanted to add that if you make a list of objects that directly reference content browser assets, you can bring them up in the content browser already selected like this (you’ll need to include “Editor/ContentBrowser/Public/ContentBrowserModule.h”):

FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
ContentBrowserModule.Get().SyncBrowserToAssets(MyUObjectTArray);
1 Like

I already use the ContentBrowserModule and Singleton for querying the selected assets, but didn’t see appropriate setters.
The next thing I wanted to try is track the behavior for the ‘show asset in content browser’ buttons that are part of the asset-widget, but couldn’t get to it yet. I should have mentioned that in my question.
But thanks for your list of references, at least I didn’t miss anything obvious during my research. :slight_smile:

Great, that was it! :smiley:
Thank you very much!