BlueprintSpawnableComponent custom icon

I have created my own C++ component which extends UActorComponent.

Is it possible to change the icon for the component (seen when you click “Add Component”), from a default white sphere, to something a bit more representative?

I’d be happy to take an icon from one of the other components, but ideally I’d provide my own.

Is this possible?

1 Like

There are a few classes you should check out:

  • FSlateStyleRegistry
  • FClassIconFinder

Startup:

auto SS = MakeShareable(new FSlateStyleSet("MyStyleSet"));

SS->SetContentRoot(FPaths::EngineContentDir() / TEXT("Editor/Slate"));
SS->SetCoreContentRoot(FPaths::EngineContentDir() / TEXT("Slate"));

auto Brush = new FSlateImageBrush("path/to/MyComponent16.png", FVector2D(16.0f, 16.0f));

SS->Set("ClassIcon.MyComponent", Brush);

FSlateStyleRegistry::RegisterSlateStyle(*SS.Get());
FClassIconFinder::RegisterIconSource(SS.Get());

Shutdown:

FClassIconFinder::UnregisterIconSource(SS.Get());
FSlateStyleRegistry::UnRegisterSlateStyle(*SS.Get());
ensure(SS.IsUnique());
SS.Reset();