What is the best way to get size of widget in viewport?

Yes, At times, Cached Geometry may not be up-to-date. You can determine whether Cached Geometry is up-to-date or not with the following function:

TakeWidget()->NeedsPrepass()

Using this function, you can wait until Cached Geometry is updated and then proceed with further tasks.

void UMyUserWidget::DoSomething()
{
	auto& timerManager = GetWorld()->GetTimerManager();
	timerManager.ClearTimer(translateMapHandle_/*this is member variable*/);
	if (TakeWidget()->NeedsPrepass())
	{
		translateMapHandle_ = timerManager.SetTimerForNextTick([this]()
		{
			DoSomething();
		});
		return;
	}
	// DoSomething with GetCachedGeometry()!
}

I hope my response proves helpful! :slight_smile:

1 Like