How to use C++ to change the colors of folders in unreal engine 5?

I created my first plugin like “Editor Toolbar Button”
With this button, a lot of folders I need are created using:
“File Manager.CreateDirectory”
How can I change the color of these folders when creating them? I’ve been looking for a solution for a very long time, but I haven’t found it.

You use this function from AssetViewUtils.h:

 * Saves the color of the path to the config
 * @param FolderPath - The path to the folder
 * @param FolderColor - The color the folder should appear as
 * @param bForceAdd - If true, force the color to be added for the path
ASSETTOOLS_API void SaveColor(const FString& FolderPath, const TSharedPtr<FLinearColor>& FolderColor, bool bForceAdd = false);

In your *.Build.cs add this:

The include:
#include "AssetViewUtils.h"

The code:

const FString Path; // Set your path here.
const TSharedPtr<FLinearColor> Color; // Set your color here
AssetViewUtils::SaveColor(Path, Color);
1 Like

I can’t figure out how to set a specific color. At the moment, the colors do not change at all. I tried to write: Black, COLOR_BLACK, (1,1,1,1). Nothing helps

In that screenshot you haven’t set the color to any value.

What if you try const TSharedPtr<FLinearColor> Color = MakeShareable(new FLinearColor(FLinearColor::Red));

You can also set the color by values using const TSharedPtr<FLinearColor> Color = MakeShareable(new FLinearColor(1.0, 0.0, 0.0));

1 Like

Take into account that the folder path needs to be in the format of "/Game/Maps" relative to the project which Unreal expects. You can’t use standard windows filenames like "D:\ProjectName\Content\Maps".

If you know how to use the Visual Studio debugging tools, you can make a breakpoint inside of AssetViewUtils::SaveColor and see what’s happening when you set the color manually in Unreal Editor to see what kind of folder names the function usually expects.

Thanks, it’s really worked. I love you, my dear friend!

1 Like