Custom Editor Mode Customization (UEdMode)

Hi, I’m trying to create custom editor mode (mainly for learning purposes). I’m created Plugin with “Editor Mode” template. Very usefull, since I didn’t find any breakdown or some “How To Create Custom Editor Mode” tutorial. This template has two tools example tools, but to get started I needed know how properly add UI things to my tool.

As I discovered there are legacy way to create new editor modes (using FEdMode), and a new one (using UEdMode). Template is using UEdMode.

I struggled to find a documented way of adding a button to details panel for a tool, so I jump to source code and looked into UInteractiveToolPropertySet. Then I had an idea.

Since properties are visible in Details Panel, I tried to add UFUNCTION(CallInEditor) right in my UTileGridMapToolProperties and delegate to be broadcasted when button is clicked.

UCLASS(Transient)
class TILEGRIDEDITOR_API UTileGridMapToolProperties : public UInteractiveToolPropertySet
{
	GENERATED_BODY()
public:
	UTileGridMapToolProperties();
	
	UFUNCTION(BlueprintCallable, CallInEditor)
	void SpawnSomething()
	{
		OnSpawnButtonClicked.Broadcast();
	};
	
	DECLARE_MULTICAST_DELEGATE(FOnSpawnButtonClicked)
	FOnSpawnButtonClicked OnSpawnButtonClicked;
};

In my UTileGridMapTool’s Setup call I bind UTileGridMapTool::OnSpawnClicked

// ...

void UTileGridMapTool::Setup()
{
    Super::Setup();
    
    Properties = NewObject<UTileGridMapToolProperties>(this);
    
    Properties->OnSpawnButtonClicked.AddUObject(this, &UTileGridMapTool::OnSpawnClicked);
    
    AddToolPropertySource(Properties);
}

void UTileGridMapTool::OnSpawnClicked()
{
	UE_LOG(LogTileGrid, Warning, TEXT("ButtonClicked"));
}

// ...

For my surprise, it worked. Button is visible in editor, I can click on it and debug text is visible.

I wanted to add a tool for spawning new TileGridMapActor (my custom class for representing map of tiles), allowing me to spawn actor and then changing shape of the map, so I could create tile map in a form of a any straight polygon. I want it to work similar to “Create New Landscape” tool in Landscape Editor, where I could setup all necessary data and only then spawn my actor by clicking on the button in details panel of the tool.

It seems I call add any button by adding CallInEditor functions in PropertySet. And properties in PropertySet are already visible in Details Panel, so I could even use EditConditions to Hide\Show some properties.

The thing is, I don’t really know if this way of adding buttons as CallInEditor function is a good, proper way for adding UI things to details panel of a tool?

Thought on that? Maybe there are proper breakdown of “moder”, non-legacy way to add new editor modes using UEdMode?