[UE4]UMG Common Notes
Keywords: UE4, UMG, 修改位置坐标
如何动态修改调整UMG组件的位置坐标(C++和蓝图)
蓝图设置坐标:
C++设置相对坐标:
Cast<UCanvasPanelSlot>( MyBtn->Slot)->SetPosition(FVector2D(X, Y));
获取相对坐标:
//ImgIcon is a UImage widget.
if (UCanvasPanelSlot* Slot = Cast<UCanvasPanelSlot>(ImgIcon->Slot))
{
FVector2D Pos = Slot->GetPosition();
}
获取绝对坐标:
ImgIcon->GetCachedGeometry().GetAbsolutePosition();
设置Widget绝对坐标:
void UWidget::SetRenderTranslation(FVector2D Translation)
设置UserWidget(比如内嵌UMG)绝对坐标:
void UUserWidget::SetPositionInViewport(FVector2D Position, bool bRemoveDPIScale )
需要的头文件:
#include <Engine/UserInterfaceSettings.h>