skip to main content
Unreal Journal

Editor Feature: Recent Assets Menu

Close up image of a person reading a menu

Intro 

We’ve had the idea of a ‘recent assets’ menu on our backlog for a while. It was highlighted again by one of our new senior programmers who had felt in the past that it would’ve been helpful functionality. So, this provided fresh impetus to explore what could be done in the area! To a certain extent, the feature already exists. The Content Browser has a filter that can be applied to display any recently used items. Nominally, this filter does what is needed, but the assets that show up depend on the folder you’re in. This means there’s a chance that the asset you’re looking for can’t be seen from where you happen to have navigated to in the Content Browser.  

Image of the Recently Opened filter option in the UE4 content browser.
Recent assets content browser filter.

Currently, under the File menu there’s a sub menu allowing access to recently opened levels. We have built a similar feature to handle other (non-level) assets. To make the recent assets menu as versatile as possible while still keeping it simple and quick to use, we’ve added an option to either open the asset in the Asset Editor or to browse to its location in the Content Browser.  

In this post we’re going to look through how this menu was created, and bring up anything noteworthy that was found on the way. 

MRUList and MRUFavoritesList 

UE4 comes with a class for storing the most recently used files (MRUList) and one that combines them with files that have been marked as favorites (MRUFavoritesList). Both the recent levels menu and the Content Browser filter we’ve mentioned have been implemented using these structures. These pre-existing classes come in handy as a lot of the functionality we’d need is already there. We’re only planning to save recent files and not the favorites though, so we’ll be fine using the MRUList class. 

Something we needed to consider is when exactly to add relevant items to the MRUList. For the Content Browser filter, items are added to the list when OpenEditorForAsset is called. This seems to make sense, but it does not treat levels and assets separately. As levels already have their own menu, we’ll want to keep the two apart. For this reason we’ll add new items to the list in the InitAssetEditor function instead. This initialisation function is called for all assets upon opening, but not for level files. It should also be noted that the most recent item is always on the top of the list, so if an item already exists on the list, it will be moved to the top. 

One issue we came across was that a part of the original MRUList class has been designed with only levels in mind. There’s a function called VerifyMRUFile which, among other things, handles situations where the associated file might’ve been deleted. The said function also happens to add a .umap ending to all file names that it gets called for. To make the MRUList class usable for any other files than maps, this needed to be changed. So instead of always attaching the .umap ending, the correct file extension will now be passed in as a parameter. 

UI and commands 

So MRUList is what we need for saving and sorting the recently used assets. Next up, let’s take a look at how the menu is structured on the UI side. A new section is added to the file menu and using the name of the section it can be placed in the right position, relative to the other sections. To create a drop down menu, we need to call the AddSubMenu function. This is bound to MakeRecentAssetsMenu, which brings up the list of recent assets this sub menu expands to. 

FToolMenuSection& Section = MainTabFileMenu->AddSection("FileRecentAssets");
{
	Section.AddSubMenu(
		"RecentAssetsSubMenu",
		LOCTEXT("RecentAssetsSubMenu", "Recent Assets"),
		LOCTEXT("RecentAssetsSubMenu_ToolTip", "Select an asset to open in asset editor"),
		FNewToolMenuDelegate::CreateStatic(&FRecentAssetsMenu::MakeRecentAssetMenu),
		false,
		FSlateIcon(FEditorStyle::GetStyleSetName(), "")
	);
}

In the MakeRecentAssetMenu() function we get the MRUList, loop through it and create another sub menu for each item on the list. This second drop down menu we add is there to display the available commands for each assetAs described before, we need to be able to open the asset in Editor or to find the asset in Content Browser. Each entry in the commands menu is added with AddMenuEntry, which also connects said entry to the actual command that will be executed when the option is selected.  

InMenu->AddSection("Open").AddMenuEntry(OpenRecentAsset, OpenAssetLabel, OpenAssetToolTip); 

Both opening the Editor for an asset and browsing to its location in the Content Browser are features that already exist elsewhere in UE4. This means that all that needed to be done was to track down the functions to trigger these events and save them up to be called from the menu. 

Summary 

And here we are with a brand new menu that helps the users find and edit any recently opened assets!  

Image of the new Recent Assets menu added to the UE4 File menu.
New Recent Assets drop down menu.

Credit(s): Tia Ylinen (Coconut Lizard)
Support: Will Hinds, Josef Gluyas (Coconut Lizard)
Status: Currently unimplemented in UE4.26
Github Pull: Pull Request #8162 · EpicGames/UnrealEngine (github.com)

Facebook Messenger Twitter Pinterest Whatsapp Email
Go to Top