Registering and unregistering tool menus

When registering Tool Menus, there’s a convenient trick to allow easy unregistration as well.

void FMyModule::RegisterMenus()
{
	FToolMenuOwnerScoped OwnerScoped(this);
 
	//Register tool menus and stuff here
}

By using FToolMenuOwnerScoped like above, the menus we register within the same scope automatically get the appropriate owner - in the above case this.

When unregistering your menus, such as in your Editor Module’s shutdown function, you can simply do:

UToolMenus::UnregisterOwner(this);