[Remote Control] Enums not properly supported in RCP

C++ and BP enum properties are handled differently, with the former not properly working with RC Controllers.

#jira UE-189659
#rb Jeremie.Roy

[CL 26608918 by Dario Mazzanti in 5.3 branch]
This commit is contained in:
Dario Mazzanti
2023-07-26 11:37:11 -04:00
parent 6931bbdcc0
commit d9a46a142a
3 changed files with 27 additions and 6 deletions

View File

@@ -252,10 +252,12 @@ void URCPropertyBindAction::Execute() const
}
// Numeric to Byte/Enum
if (RemoteControlProperty->IsA(FByteProperty::StaticClass()))
if (RemoteControlProperty->IsA(FByteProperty::StaticClass()) ||
RemoteControlProperty->IsA(FEnumProperty::StaticClass()))
{
Handle->SetValue((uint8)NumericValue);
}
// Numeric To Numeric
if (RemoteControlProperty->IsA(FNumericProperty::StaticClass()))
{

View File

@@ -161,6 +161,19 @@ bool URCBehaviourBind::CanHaveActionForField(URCController* Controller, TSharedR
return false; // Unbound Property
}
// Enums with base other than 8bits should be ignored, so let's make sure of that
if (const FEnumProperty* EnumProperty = CastField<FEnumProperty>(RemoteControlProperty))
{
if (const UEnum* Enum = EnumProperty->GetEnum())
{
const int64 MaxEnumValue = Enum->GetMaxEnumValue();
const uint32 NeededBits = FMath::RoundUpToPowerOfTwo(MaxEnumValue);
// 8 bits enums only
return NeededBits <= 256;
}
}
// Indirect Binding (related types)
//
const static TMap<FFieldClass*, TArray<FFieldClass*>> SupportedIndirectBindsMap =
@@ -168,7 +181,7 @@ bool URCBehaviourBind::CanHaveActionForField(URCController* Controller, TSharedR
/* Controller Type */ /* Supported Remote Control Property Types */
{ FStrProperty::StaticClass(), /* --> */ { FTextProperty::StaticClass(), FNameProperty::StaticClass()}},
{ FNumericProperty::StaticClass(), /* --> */ { FNumericProperty::StaticClass(), FBoolProperty::StaticClass(), FByteProperty::StaticClass() } },
{ FNumericProperty::StaticClass(), /* --> */ { FNumericProperty::StaticClass(), FBoolProperty::StaticClass(), FByteProperty::StaticClass(), FEnumProperty::StaticClass() } },
{ FBoolProperty::StaticClass(), /* --> */ { FFloatProperty::StaticClass(), FIntProperty::StaticClass(), FBoolProperty::StaticClass() } }
};

View File

@@ -807,11 +807,17 @@ bool SRCControllerPanelList::IsEntitySupported(const FGuid ExposedEntityId)
if (RemoteControlProperty->FieldType == EExposedFieldType::Property)
{
const FProperty* Property = RemoteControlProperty->GetProperty();
// enums are currently not properly supported by controllers (e.g. C++ enums action binding won't work)
if (Property->IsA<FEnumProperty>())
if (const FEnumProperty* EnumProperty = CastField<FEnumProperty>(Property))
{
return false;
if (const UEnum* Enum = EnumProperty->GetEnum())
{
const int64 MaxEnumValue = Enum->GetMaxEnumValue();
const uint32 NeededBits = FMath::RoundUpToPowerOfTwo(MaxEnumValue);
// 8 bits enums only
return NeededBits <= 256;
}
}
else if (const FStructProperty* StructProperty = CastField<FStructProperty>(Property))
{