// Copyright PICO Technology Co., Ltd. All rights reserved. // This plugin incorporates portions of the UnrealĀ® Engine. UnrealĀ® is a trademark or registered trademark of Epic Games, Inc. in the United States of America and elsewhere. // Copyright Epic Games, Inc. All Rights Reserved. #pragma once namespace PXRUtility { template T* FindComponentByName(AActor* Actor, const FName& ComponentName) { if (IsValid(Actor) && (ComponentName != NAME_None)) { TArray ComponentsOfType; Actor->GetComponents(ComponentsOfType); T** FoundComponent = ComponentsOfType.FindByPredicate([Name = ComponentName.ToString()](T* Component) { return Component->GetName().Equals(Name); }); if (FoundComponent != nullptr) { return *FoundComponent; } } return nullptr; } }