I’m working on some UMG project for designers can edit layout different in landscape and portrait.
It saves current CanvasPanelSlot data in landscape and portrait differently, so when designer change screen orientation, it changes slot layout with data saved before.
Those Custom Canvas Panel propertys are UPROPERTY and orignally, it was designed for only visible in editor. When designers change Canvas Panel Slot, it detect changes and set value in Portrait Slot or Landscape Slot what i made and categorized in Custom Canvas Panel.
#if WITH_EDITOR
void UCustomCanvasPanel::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
if (PropertyChangedEvent.Property->GetName() != FString("Slot"))
return;
UCanvasPanelSlot* currentSlot = Cast<UCanvasPanelSlot>(Slot);
if (!currentSlot)
return;
if (CurrentScreenOrientation == ECustomScreenOrientation::Landscape)
{
LandscapeSlot.Anchors = currentSlot->GetAnchors();
LandscapeSlot.Offset = currentSlot->GetOffsets();
LandscapeSlot.Alignment = currentSlot->GetAlignment();
FObjectEditorUtils::SetPropertyValue<UCustomCanvasPanel, FCanvasSlotData>(this, FName("LandscapeSlot"), LandscapeSlot);
}
else
{
PortraitSlot.Anchors = currentSlot->GetAnchors();
PortraitSlot.Offset = currentSlot->GetOffsets();
PortraitSlot.Alignment = currentSlot->GetAlignment();
FObjectEditorUtils::SetPropertyValue<UCustomCanvasPanel, FCanvasSlotData>(this, FName("PortraitSlot"), PortraitSlot);
}
}
#endif
But I have a problem with reflection. When I change Canvas Panel Slot data, it saves to value to slot data struct what i made. But when I hit the compile button, slot data was reset.
First I was set value with just =operator and I’ve tried with FObjectEditorUtils::SetPropertyValue but i got a same problem.
And I found one thing strange. When I directly set value to data struct, not through editing CanvasPanelSlot, It saves value and just works fine with this values. But what i set on code, it was reset.
Of course, compile button what I said is this.
Not this.
So DO NOT JUST trying to say YOU SHOULD DISABLE HOT RELOAD if you don’t want to make me stress out, PLEAZE.
I was heard this for 10 times but I already disabled hot reload about 2 years ago.