本文整理汇总了C++中FMenuBuilder::PushExtender方法的典型用法代码示例。如果您正苦于以下问题:C++ FMenuBuilder::PushExtender方法的具体用法?C++ FMenuBuilder::PushExtender怎么用?C++ FMenuBuilder::PushExtender使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FMenuBuilder
的用法示例。
在下文中一共展示了FMenuBuilder::PushExtender方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillMenu
void FLevelEditorContextMenu::FillMenu( FMenuBuilder& MenuBuilder, TWeakPtr<SLevelEditor> LevelEditor, LevelEditorMenuContext ContextType, TSharedPtr<FExtender> Extender )
{
// Generate information about our selection
TArray<AActor*> SelectedActors;
GEditor->GetSelectedActors()->GetSelectedObjects<AActor>( SelectedActors );
FSelectedActorInfo& SelectionInfo = FLevelEditorContextMenuImpl::SelectionInfo;
SelectionInfo = AssetSelectionUtils::BuildSelectedActorInfo( SelectedActors );
// Get all menu extenders for this context menu from the level editor module
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>( TEXT("LevelEditor") );
TArray<FLevelEditorModule::FLevelViewportMenuExtender_SelectedActors> MenuExtenderDelegates = LevelEditorModule.GetAllLevelViewportContextMenuExtenders();
TArray<TSharedPtr<FExtender>> Extenders;
if(Extender.IsValid())
{
Extenders.Add(Extender);
}
auto LevelEditorActions = LevelEditor.Pin()->GetLevelEditorActions().ToSharedRef();
for (int32 i = 0; i < MenuExtenderDelegates.Num(); ++i)
{
if (MenuExtenderDelegates[i].IsBound())
{
Extenders.Add(MenuExtenderDelegates[i].Execute(LevelEditorActions, SelectedActors));
}
}
MenuBuilder.PushCommandList(LevelEditorActions);
MenuBuilder.PushExtender(FExtender::Combine(Extenders).ToSharedRef());
TArray<TWeakObjectPtr<UObject>> LabelObjects;
for ( FSelectionIterator SelItor(*GEditor->GetSelectedActors()) ; SelItor ; ++SelItor )
{
LabelObjects.Add(*SelItor);
}
// Check if current selection has any assets that can be browsed to
TArray< UObject* > ReferencedAssets;
GEditor->GetReferencedAssetsForEditorSelection( ReferencedAssets );
const bool bCanSyncToContentBrowser = GEditor->CanSyncToContentBrowser();
if( bCanSyncToContentBrowser || ReferencedAssets.Num() > 0 )
{
MenuBuilder.BeginSection("ActorAsset", LOCTEXT("AssetHeading", "Asset") );
{
if( bCanSyncToContentBrowser )
{
MenuBuilder.AddMenuEntry( FGlobalEditorCommonCommands::Get().FindInContentBrowser );
}
if( ReferencedAssets.Num() == 1 )
{
auto Asset = ReferencedAssets[0];
MenuBuilder.AddMenuEntry(
FLevelEditorCommands::Get().EditAsset,
NAME_None,
FText::Format( LOCTEXT("EditAssociatedAsset", "Edit {0}"), FText::FromString( Asset->GetName() ) ),
TAttribute<FText>(),
FSlateIcon( FEditorStyle::GetStyleSetName(), FClassIconFinder::FindIconNameForClass( Asset->GetClass() ) )
);
}
else if ( ReferencedAssets.Num() > 1 )
{
MenuBuilder.AddMenuEntry(
FLevelEditorCommands::Get().EditAssetNoConfirmMultiple,
NAME_None,
LOCTEXT("EditAssociatedAssetsMultiple", "Edit Multiple Assets"),
TAttribute<FText>(),
FSlateIcon( FEditorStyle::GetStyleSetName(), "ClassIcon.Default" )
);
}
MenuBuilder.AddMenuEntry( FGlobalEditorCommonCommands::Get().ViewReferences );
}
MenuBuilder.EndSection();
}
MenuBuilder.BeginSection( "ActorControl", LOCTEXT("ActorHeading", "Actor") );
{
MenuBuilder.AddMenuEntry( FEditorViewportCommands::Get().FocusViewportToSelection );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().SnapCameraToActor );
}
MenuBuilder.EndSection();
// Go to C++ Code
if( SelectionInfo.SelectionClass != NULL )
{
if ( FSourceCodeNavigation::IsCompilerAvailable())
{
FString ClassHeaderPath;
if( FSourceCodeNavigation::FindClassHeaderPath( SelectionInfo.SelectionClass, ClassHeaderPath ) && IFileManager::Get().FileSize( *ClassHeaderPath ) != INDEX_NONE )
{
const FString CodeFileName = FPaths::GetCleanFilename( *ClassHeaderPath );
//.........这里部分代码省略.........
示例2: BuildContextMenu
void FSequencerObjectBindingNode::BuildContextMenu(FMenuBuilder& MenuBuilder)
{
ISequencerModule& SequencerModule = FModuleManager::GetModuleChecked<ISequencerModule>("Sequencer");
UObject* BoundObject = GetSequencer().FindSpawnedObjectOrTemplate(ObjectBinding);
TSharedRef<FUICommandList> CommandList(new FUICommandList);
TSharedPtr<FExtender> Extender = SequencerModule.GetObjectBindingContextMenuExtensibilityManager()->GetAllExtenders(CommandList, TArrayBuilder<UObject*>().Add(BoundObject));
if (Extender.IsValid())
{
MenuBuilder.PushExtender(Extender.ToSharedRef());
}
if (GetSequencer().IsLevelEditorSequencer())
{
UMovieScene* MovieScene = GetSequencer().GetFocusedMovieSceneSequence()->GetMovieScene();
FMovieSceneSpawnable* Spawnable = MovieScene->FindSpawnable(ObjectBinding);
if (Spawnable)
{
MenuBuilder.AddSubMenu(
LOCTEXT("OwnerLabel", "Spawned Object Owner"),
LOCTEXT("OwnerTooltip", "Specifies how the spawned object is to be owned"),
FNewMenuDelegate::CreateSP(this, &FSequencerObjectBindingNode::AddSpawnOwnershipMenu)
);
MenuBuilder.AddMenuEntry( FSequencerCommands::Get().ConvertToPossessable );
}
else
{
const UClass* ObjectClass = GetClassForObjectBinding();
if (ObjectClass->IsChildOf(AActor::StaticClass()))
{
FFormatNamedArguments Args;
MenuBuilder.AddSubMenu(
FText::Format( LOCTEXT("Assign Actor ", "Assign Actor"), Args),
FText::Format( LOCTEXT("AssignActorTooltip", "Assign an actor to this track"), Args ),
FNewMenuDelegate::CreateRaw(&GetSequencer(), &FSequencer::AssignActor, ObjectBinding));
}
MenuBuilder.AddMenuEntry( FSequencerCommands::Get().ConvertToSpawnable );
}
MenuBuilder.AddMenuEntry(
LOCTEXT("Import FBX", "Import..."),
LOCTEXT("ImportFBXTooltip", "Import FBX animation to this object"),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateLambda([=]{ GetSequencer().ImportFBX(); })
));
MenuBuilder.AddMenuEntry(
LOCTEXT("Export FBX", "Export..."),
LOCTEXT("ExportFBXTooltip", "Export FBX animation from this object"),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateLambda([=]{ GetSequencer().ExportFBX(); })
));
MenuBuilder.BeginSection("Organize", LOCTEXT("OrganizeContextMenuSectionName", "Organize"));
{
MenuBuilder.AddSubMenu(
LOCTEXT("LabelsSubMenuText", "Labels"),
LOCTEXT("LabelsSubMenuTip", "Add or remove labels on this track"),
FNewMenuDelegate::CreateSP(this, &FSequencerObjectBindingNode::HandleLabelsSubMenuCreate)
);
}
MenuBuilder.EndSection();
}
FSequencerDisplayNode::BuildContextMenu(MenuBuilder);
}