38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
#include "PawnEditor/Customization/PwnInteractableActorCustomization.h"
|
|
|
|
#include "PropertyCustomizationHelpers.h"
|
|
#include "PropertyHandle.h"
|
|
#include "Interaction/PwnInteractable.h"
|
|
|
|
TSharedRef<IPropertyTypeCustomization> UPwnInteractableActorCustomization::MakeInstance() {
|
|
return MakeShareable(new UPwnInteractableActorCustomization());
|
|
}
|
|
|
|
void UPwnInteractableActorCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> StructPropertyHandle, FDetailWidgetRow& HeaderRow,
|
|
IPropertyTypeCustomizationUtils& StructCustomizationUtils) {
|
|
const TSharedPtr<IPropertyHandle> ActorReferenceProperty = StructPropertyHandle->GetChildHandle(TEXT("ActorReference"));
|
|
|
|
HeaderRow
|
|
.NameContent()
|
|
[
|
|
StructPropertyHandle->CreatePropertyNameWidget()
|
|
]
|
|
.ValueContent()
|
|
[
|
|
SNew(SObjectPropertyEntryBox)
|
|
.PropertyHandle(ActorReferenceProperty)
|
|
.OnShouldFilterActor(FOnShouldFilterActor::CreateStatic(OnShouldFilterActor))
|
|
.AllowedClass(AActor::StaticClass())
|
|
.AllowClear(true)
|
|
];
|
|
}
|
|
|
|
void UPwnInteractableActorCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, IDetailChildrenBuilder& StructBuilder,
|
|
IPropertyTypeCustomizationUtils& StructCustomizationUtils) {
|
|
// Do nothing
|
|
}
|
|
|
|
bool UPwnInteractableActorCustomization::OnShouldFilterActor(const AActor* Actor) {
|
|
return Actor->GetClass()->ImplementsInterface(UPwnInteractable::StaticClass());
|
|
}
|