Hello,
I’m looking for a way of changing the icon that displays on macro nodes or custom nodes placed in Blueprint Graph.
Many of default Unreal nodes use custom icons so I believe this is somehow possible to do.
Espesially the ...\Engine\Content\EditorBlueprintResources\StandardMacros.uasset
has so many stuff with cutom icons in it:
I already tried to reverse engineer the logic behind it and found this .cpp::
https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Editor/BlueprintGraph/Private/K2Node_MacroInstance.cpp
In which there is code that probably handles the replacement of icons:
FSlateIcon UK2Node_MacroInstance::GetIconAndTint(FLinearColor& OutColor) const
{
const char* IconName = "GraphEditor.Macro_16x";
// Special case handling for standard macros
// @TODO Change this to a SlateBurushAsset pointer on the graph or something similar, to allow any macro to have an icon
UEdGraph* MacroGraph = MacroGraphReference.GetGraph();
if(MacroGraph != nullptr && MacroGraph->GetOuter()->GetName() == TEXT("StandardMacros"))
{
FName MacroName = FName(*MacroGraph->GetName());
if( MacroName == TEXT("ForLoop" ) ||
MacroName == TEXT("ForLoopWithBreak") ||
MacroName == TEXT("WhileLoop") )
{
IconName = "GraphEditor.Macro.Loop_16x";
}
/* There is just more else-if's that works exacly the same way as the if statement above */
}
return FSlateIcon("EditorStyle", IconName);
}
But I’m not really sure what shall I do with all of it since I’ve never used K2Node_MacroInstance.h
.
How can I apply the same icon-swapping logic for custom nodes/macros that I’ve created in my project/plugin ?
I’ll really appreciate any answers
Also this topic was partially asked (but not answered) in this very old post: