本文整理汇总了C++中TArray::FindByPredicate方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::FindByPredicate方法的具体用法?C++ TArray::FindByPredicate怎么用?C++ TArray::FindByPredicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::FindByPredicate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindGraphByName
static UEdGraph* FindGraphByName(UBlueprint const& FromBlueprint, const FName& GraphName)
{
TArray<UEdGraph*> Graphs;
FromBlueprint.GetAllGraphs(Graphs);
UEdGraph* Ret = nullptr;
if (UEdGraph** Result = Graphs.FindByPredicate(FMatchFName(GraphName)))
{
Ret = *Result;
}
return Ret;
}
示例2: FindEditorForAsset
IAssetEditorInstance* FAssetEditorManager::FindEditorForAsset(UObject* Asset, bool bFocusIfOpen)
{
const TArray<IAssetEditorInstance*> AssetEditors = FindEditorsForAsset(Asset);
IAssetEditorInstance* const * PrimaryEditor = AssetEditors.FindByPredicate( [](IAssetEditorInstance* Editor){ return Editor->IsPrimaryEditor(); } );
const bool bEditorOpen = PrimaryEditor != NULL;
if (bEditorOpen && bFocusIfOpen)
{
// @todo toolkit minor: We may need to handle this differently for world-centric vs standalone. (multiple level editors, etc)
(*PrimaryEditor)->FocusWindow(Asset);
}
return bEditorOpen ? *PrimaryEditor : NULL;
}
示例3:
TSharedPtr<FPropertyEditorToolkit> FPropertyEditorToolkit::FindExistingEditor( UObject* Object )
{
// Find any existing property editor instances for this asset
const TArray<IAssetEditorInstance*> Editors = FAssetEditorManager::Get().FindEditorsForAsset( Object );
IAssetEditorInstance* const * ExistingInstance = Editors.FindByPredicate( [&]( IAssetEditorInstance* Editor ){
return Editor->GetEditorName() == ToolkitFName;
} );
if( ExistingInstance )
{
auto* PropertyEditor = static_cast<FPropertyEditorToolkit*>( *ExistingInstance );
return PropertyEditor->SharedThis( PropertyEditor );
}
return nullptr;
}
示例4: OnResetEmitter
FReply FParticleSystemComponentDetails::OnResetEmitter()
{
const TArray< TWeakObjectPtr<UObject> >& SelectedObjects = DetailLayout->GetDetailsView().GetSelectedObjects();
// Iterate over selected Actors.
for (int32 Idx = 0; Idx < SelectedObjects.Num(); ++Idx)
{
if (SelectedObjects[Idx].IsValid())
{
UParticleSystemComponent* PSC = Cast<UParticleSystemComponent>(SelectedObjects[Idx].Get());
if (!PSC)
{
if (AEmitter* Emitter = Cast<AEmitter>(SelectedObjects[Idx].Get()))
{
PSC = Emitter->GetParticleSystemComponent();
}
}
// If the object selected to the details view is a template, then we need to redirect the reset to the preview instance (e.g. in the Blueprint editor).
// @todo Can remove this if we switch to instance-based editing in the Blueprint editor.
if (PSC && PSC->IsTemplate())
{
TArray<UObject*> Instances;
PSC->GetArchetypeInstances(Instances);
UObject** ElementPtr = Instances.FindByPredicate([](const UObject* Element)
{
const AActor* Owner = Cast<AActor>(Element->GetOuter());
return Owner != nullptr && FActorEditorUtils::IsAPreviewOrInactiveActor(Owner);
});
if (ElementPtr)
{
PSC = Cast<UParticleSystemComponent>(*ElementPtr);
}
}
if (PSC)
{
PSC->ResetParticles();
PSC->ActivateSystem();
}
}
}
return FReply::Handled();
}
示例5: AddSortedSpriteInfo
static void AddSortedSpriteInfo(TArray<FSpriteCategoryInfo>& InOutSortedSpriteInfo, const FSpriteCategoryInfo& InSpriteInfo )
{
const FSpriteCategoryInfo* ExistingSpriteInfo = InOutSortedSpriteInfo.FindByPredicate([&InSpriteInfo](const FSpriteCategoryInfo& SpriteInfo){ return InSpriteInfo.Category == SpriteInfo.Category; });
if (ExistingSpriteInfo != NULL)
{
//Already present
checkSlow(ExistingSpriteInfo->DisplayName.EqualTo(InSpriteInfo.DisplayName)); //Catch mismatches between DisplayNames
}
else
{
// Add the category to the correct position in the array to keep it sorted
const int32 CatIndex = InOutSortedSpriteInfo.IndexOfByPredicate([&InSpriteInfo](const FSpriteCategoryInfo& SpriteInfo){ return InSpriteInfo.DisplayName.CompareTo( SpriteInfo.DisplayName ) < 0; });
if (CatIndex != INDEX_NONE)
{
InOutSortedSpriteInfo.Insert( InSpriteInfo, CatIndex );
}
else
{
InOutSortedSpriteInfo.Add( InSpriteInfo );
}
}
}
示例6: BuildPlatformHierarchy
TArray<FVanillaPlatformEntry> BuildPlatformHierarchy(const EPlatformFilter InFilter)
{
TArray<FVanillaPlatformEntry> VanillaPlatforms;
// Build up a tree from the platforms we support (vanilla outers, with a list of flavors)
// PlatformInfoArray should be ordered in such a way that the vanilla platforms always appear before their flavors
for(const FPlatformInfo& PlatformInfo : PlatformInfoArray)
{
if(PlatformInfo.IsVanilla())
{
VanillaPlatforms.Add(FVanillaPlatformEntry(&PlatformInfo));
}
else
{
const bool bHasBuildFlavor = !!(PlatformInfo.PlatformFlags & EPlatformFlags::BuildFlavor);
const bool bHasCookFlavor = !!(PlatformInfo.PlatformFlags & EPlatformFlags::CookFlavor);
const bool bValidFlavor =
InFilter == EPlatformFilter::All ||
(InFilter == EPlatformFilter::BuildFlavor && bHasBuildFlavor) ||
(InFilter == EPlatformFilter::CookFlavor && bHasCookFlavor);
if(bValidFlavor)
{
const FName VanillaPlatformName = PlatformInfo.VanillaPlatformName;
FVanillaPlatformEntry* const VanillaEntry = VanillaPlatforms.FindByPredicate([VanillaPlatformName](const FVanillaPlatformEntry& Item) -> bool
{
return Item.PlatformInfo->PlatformInfoName == VanillaPlatformName;
});
check(VanillaEntry);
VanillaEntry->PlatformFlavors.Add(&PlatformInfo);
}
}
}
return VanillaPlatforms;
}
示例7: RunTest
/**
* Take screenshots of the SME window with each of the toolbar buttons toggled separately
*/
bool FStaticMeshEditorTest::RunTest(const FString& Parameters)
{
TArray<FString> ButtonNamesToTestFor;
FString LoadedObjectType = TEXT("EditorCylinder");
FString MeshName;
EditorViewButtonHelper::PerformStaticMeshFlagParameters AutomationParameters;
WindowScreenshotParameters WindowParameters;
//Pull from .ini the names of the buttons we want to test for
GConfig->GetString( TEXT("AutomationTesting"), TEXT("EditorViewButtonsObject"), LoadedObjectType, GEngineIni);
//Open static mesh in the editor and save out the window for the screenshots
UObject* EditorMesh = (UStaticMesh*)StaticLoadObject(UStaticMesh::StaticClass(),
NULL,
*FString::Printf(TEXT("/Engine/EditorMeshes/%s.%s"), *LoadedObjectType, *LoadedObjectType),
NULL,
LOAD_None,
NULL);
FAssetEditorManager::Get().OpenEditorForAsset(EditorMesh);
{
TArray<TSharedRef<SWindow>> AllWindows;
FSlateApplication::Get().GetAllVisibleWindowsOrdered(AllWindows);
const FText ExpectedTitle = FText::FromString(LoadedObjectType);
if (auto* Window = AllWindows.FindByPredicate([&](const TSharedRef<SWindow>& In) { return In->GetTitle().EqualTo(ExpectedTitle); }))
{
WindowParameters.CurrentWindow = *Window;
}
}
if (!WindowParameters.CurrentWindow.IsValid())
{
AddError(TEXT("Could not find static mesh editor window"));
return false;
}
//Grab the last opened Viewport (aka the asset manager)
AutomationParameters.ViewportClient = static_cast<FStaticMeshEditorViewportClient*>(GEditor->AllViewportClients[GEditor->AllViewportClients.Num() - 1]);
AutomationParameters.CommandType = EditorViewButtonHelper::EStaticMeshFlag::Wireframe; //Start it off at Wireframe because that is the first button we are attempting to press
if (AutomationParameters.ViewportClient)
{
const FString BaseFileName = TEXT("StaticMeshEditorTest");
FString TestName = FString::Printf(TEXT("%s/Base"), *BaseFileName);
//Wait for the window to load and then take the initial screen shot
ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(0.5f));
if( FAutomationTestFramework::GetInstance().IsScreenshotAllowed() )
{
AutomationCommon::GetScreenshotPath(TestName, WindowParameters.ScreenshotName, false);
ADD_LATENT_AUTOMATION_COMMAND(FTakeEditorScreenshotCommand(WindowParameters));
ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(0.1f));
}
for(auto CurrentCommandType = 0; CurrentCommandType < EditorViewButtonHelper::EStaticMeshFlag::Max; ++CurrentCommandType)
{
TestName = FString::Printf(TEXT("%s/%s"), *BaseFileName, EditorViewButtonHelper::GetStaticMeshFlagName(AutomationParameters.CommandType));
//Toggle the command for the button, take a screenshot, and then re-toggle the command for the button
ADD_LATENT_AUTOMATION_COMMAND(EditorViewButtonHelper::FPerformStaticMeshFlagToggle(AutomationParameters));
ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(0.1f));
if( FAutomationTestFramework::GetInstance().IsScreenshotAllowed() )
{
//Take the screenshot
AutomationCommon::GetScreenshotPath(TestName, WindowParameters.ScreenshotName, false);
ADD_LATENT_AUTOMATION_COMMAND(FTakeEditorScreenshotCommand(WindowParameters));
//Wait so the screenshots have a chance to save
ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(0.1f));
}
//Toggle the flag back off
ADD_LATENT_AUTOMATION_COMMAND(EditorViewButtonHelper::FPerformStaticMeshFlagToggle(AutomationParameters));
//Increment to the next enum, so we can loop through all the types
AutomationParameters.CommandType = (EditorViewButtonHelper::EStaticMeshFlag::Type)((int)AutomationParameters.CommandType + 1);
}
ADD_LATENT_AUTOMATION_COMMAND(EditorViewButtonHelper::FCloseAllAssetEditorsCommand());
}
return true;
}