Boon
(Boon)
February 18, 2023, 6:46pm
1
I’m doing something wrong but I can’t figure it out.
TSharedPtr<IPropertyHandle> ColorProperty;
void FColorHandler::OnColorCommitted(FLinearColor LinearColor)
{
UE_LOG(LogTemp, Warning, TEXT("%s"), *FString("Color committed:" + LinearColor.ToString()));
FVector4 OutColor = FVector4(LinearColor);
UE_LOG(LogTemp, Warning, TEXT("%s"), *FString("Color to Vector: " + OutColor.ToString()));
//ColorProperty->SetValue(OutColor)
ColorProperty->SetValue(LinearColor);
FVector4 CheckValue;
ColorProperty->GetValue(CheckValue);
UE_LOG(LogTemp, Warning, TEXT("%s"), *FString("Resulting value: " + CheckValue.ToString()))
}
I’ve tried setting the color as a FLinearColor and FVector4, both report the correct value before the SetValue operation, but return <0,0,0,1> after the SetValue.
Warning LogTemp Color committed (R=1.000000,G=0.000000,B=0.000000,A=0.000000)
Warning LogTemp Color to Vector: X=1.000 Y=0.000 Z=0.000 W=0.000
Warning LogTemp Resulting value: X=0.000 Y=0.000 Z=0.000 W=1.000
Boon
(Boon)
February 18, 2023, 7:00pm
2
I also tried setting the child properties:
TSharedPtr<IPropertyHandle> RH = ColorProperty->GetChildHandle(GET_MEMBER_NAME_CHECKED(FLinearColor, R));
TSharedPtr<IPropertyHandle> GH = ColorProperty->GetChildHandle(GET_MEMBER_NAME_CHECKED(FLinearColor, G));
TSharedPtr<IPropertyHandle> BH = ColorProperty->GetChildHandle(GET_MEMBER_NAME_CHECKED(FLinearColor, B));
TSharedPtr<IPropertyHandle> AH = ColorProperty->GetChildHandle(GET_MEMBER_NAME_CHECKED(FLinearColor, A));
check (RH.IsValid() && RH->IsValidHandle() && GH.IsValid() && GH->IsValidHandle() &&
BH.IsValid() && BH->IsValidHandle() && AH.IsValid() && AH->IsValidHandle())
RH->SetValue(LinearColor.R);
GH->SetValue(LinearColor.G);
BH->SetValue(LinearColor.B);
AH->SetValue(LinearColor.A);
FVector4 CheckValue;
ColorProperty->GetValue(CheckValue);
UE_LOG(LogTemp, Warning, TEXT("%s"), *FString("New color: " + CheckValue.ToString()));
Still returns that the resulting value is <0,0,0,1>
Boon
(Boon)
February 19, 2023, 1:46am
3
It’s occurred to me that because FLinearColor is a struct, when I attempt to SetValue I may be setting a copy? I’m not sure how to test/fix that though.