Im trying to do a button on the main toolbar that only be visible with an specific class, but the
using AddDynamicEntry, dont proc FNewToolMenuSectionDelegate, Register Menu! is appearing, when i debug
the menu is ok
void UGASAttributeSubsystem::RegisterMenus()
{
UE_LOG(LogTemp, Warning, TEXT("Register Menu!"));
UToolMenu* ToolbarMenu = UToolMenus::Get()->ExtendMenu("AssetEditor.BlueprintEditor.ToolBar.Defaults");
FToolMenuSection& Section = ToolbarMenu->FindOrAddSection("GasAttributes");
/*Section.AddDynamicEntry(
FName(TEXT("AddAttributeButton")),
//FNewToolMenuSectionDelegate::CreateUObject(this, &UGASAttributeSubsystem::BuildAddAttributeMenu)
FNewToolMenuSectionDelegate::CreateLambda([this](FToolMenuSection& InSection)
{
UE_LOG(LogTemp, Warning, TEXT("Lambda ejecutado"));
UToolMenu* Menu = InSection.FindContext<UToolMenu>();
if (Menu)
{
UE_LOG(LogTemp, Warning, TEXT("Hay Contexto de Menu"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("No Hay Contexto de Menu"));
}
})
);*/
UToolMenus::Get()->RefreshAllWidgets();
}
void UGASAttributeSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);
// Register the extension point in the Blueprint editor toolbar
UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateUObject(this, &UGASAttributeSubsystem::RegisterMenus));
if (GEditor) {
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OnEditorOpeningPreWidgets().AddUObject(this, &UGASAttributeSubsystem::OnAssetOpened);
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OnAssetClosedInEditor().AddUObject(this, &UGASAttributeSubsystem::clearAsset);
}
}
On the other hand OnAssetOpened, clearAsset works like a charm,
what im missing?