UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ToolBuilderUtil.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Algo/Count.h"
7#include "Algo/Find.h"
9#include "Engine/Selection.h"
11
16{
19 int CountComponents(const FToolBuilderState& InputState, const TFunction<bool(UActorComponent*)>& Predicate);
20
24
28
29 // @todo not sure that actors with multiple components are handled properly...
31 template<typename ComponentType>
33
35 template<typename ComponentType>
37
40
43 int32 CountActors(const FToolBuilderState& InputState, const TFunction<bool(AActor*)>& Predicate);
44
47 AActor* FindFirstActor(const FToolBuilderState& InputState, const TFunction<bool(AActor*)>& Predicate);
48
52
54 template<typename ActorType>
56
58 template<typename ActorType>
60
64
68}
69
70/*
71 * Template Implementations
72 */
73template<typename ComponentType>
78
79template<typename ComponentType>
81{
82 return static_cast<ComponentType*>(FindFirstComponent(InputState, [](UActorComponent* Component) { return Cast<ComponentType>(Component) != nullptr; }));
83}
84
85template<typename ActorType>
90
91template<typename ActorType>
93{
94 AActor* Found = FindFirstActor(InputState, [](AActor* Actor) { return Cast<ActorType>(Actor) != nullptr; });
95 return (Found != nullptr) ? Cast<ActorType>(Found) : nullptr;
96}
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Actor.h:257
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
Definition ActorComponent.h:152
Definition ToolBuilderUtil.h:16
INTERACTIVETOOLSFRAMEWORK_API void EnumerateComponents(const FToolBuilderState &InputState, TFunctionRef< void(UActorComponent *)> ComponentFunc)
Definition ToolBuilderUtil.cpp:88
INTERACTIVETOOLSFRAMEWORK_API bool IsVolume(const UActorComponent &Component)
Definition ToolBuilderUtil.cpp:141
ComponentType * FindFirstComponentOfType(const FToolBuilderState &InputState)
Definition ToolBuilderUtil.h:80
ActorType * FindFirstActorOfType(const FToolBuilderState &InputState)
Definition ToolBuilderUtil.h:92
INTERACTIVETOOLSFRAMEWORK_API UActorComponent * FindFirstComponent(const FToolBuilderState &InputState, const TFunction< bool(UActorComponent *)> &Predicate)
Definition ToolBuilderUtil.cpp:36
INTERACTIVETOOLSFRAMEWORK_API int CountComponents(const FToolBuilderState &InputState, const TFunction< bool(UActorComponent *)> &Predicate)
Definition ToolBuilderUtil.cpp:12
INTERACTIVETOOLSFRAMEWORK_API TArray< AActor * > FindAllActors(const FToolBuilderState &InputState, const TFunction< bool(AActor *)> &Predicate)
Definition ToolBuilderUtil.cpp:129
INTERACTIVETOOLSFRAMEWORK_API AActor * FindFirstActor(const FToolBuilderState &InputState, const TFunction< bool(AActor *)> &Predicate)
Definition ToolBuilderUtil.cpp:118
int CountSelectedComponentsOfType(const FToolBuilderState &InputState)
Definition ToolBuilderUtil.h:74
INTERACTIVETOOLSFRAMEWORK_API TArray< UActorComponent * > FindAllComponents(const FToolBuilderState &InputState, const TFunction< bool(UActorComponent *)> &Predicate)
Definition ToolBuilderUtil.cpp:63
INTERACTIVETOOLSFRAMEWORK_API int32 CountActors(const FToolBuilderState &InputState, const TFunction< bool(AActor *)> &Predicate)
Definition ToolBuilderUtil.cpp:112
int CountSelectedActorsOfType(const FToolBuilderState &InputState)
Definition ToolBuilderUtil.h:86
INTERACTIVETOOLSFRAMEWORK_API bool ComponentTypeCouldHaveUVs(const UActorComponent &Component)
Definition ToolBuilderUtil.cpp:135
Definition ToolContextInterfaces.h:50