KhalimWu
(KhalimWu)
July 22, 2016, 5:44am
1
I got an inventory widget with another widget inside, which has a scrollbox and inside there are children (each one is another widget). basically i need the exact position of one of the children inside the scrollbox (need to create an animation, using the current position of that widget on the viewport and move the widget to another area). Current options (on blueprint) are only “Slot as”, which dont include scrollbox.
Thanks
Did you ever figure this out?
…Did you ever figure this out?.. I got the same problem…,…Did you ever figure this out?.. I got the same problem…
If you are using 4.15. This code connected two buttons by line.
If you use blueprints then look here UMG getting the screen position of a child widget - UI - Epic Developer Community Forums comment by Rudy Triplett Mar 27 '17 at 4:12 PM
#include "Blueprint/WidgetBlueprintLibrary.h"
#include "Blueprint/SlateBlueprintLibrary.h"
void UWidgetResearch::NativePaint(FPaintContext& InContext) const
{
Super::NativePaint(InContext);
const FGeometry& geom = pUButtonResearch->GetCachedGeometry();
FVector2D Pos1 = geom.AbsolutePosition;
Pos1.Y += geom.GetDrawSize().Y / 2;
FVector2D PixelPosition, ViewportPosition;
USlateBlueprintLibrary::AbsoluteToViewport(AGod::GODRef->GetWorld(), Pos1, PixelPosition, ViewportPosition);
const FGeometry& geom2 = pUButtonResearchDependent->GetCachedGeometry();
FVector2D Pos2 = geom2.AbsolutePosition;
Pos2.X += geom2.GetDrawSize().X;
Pos2.Y += geom2.GetDrawSize().Y / 2;
FVector2D PixelPosition2, ViewportPosition2;
USlateBlueprintLibrary::AbsoluteToViewport(AGod::GODRef->GetWorld(), Pos2, PixelPosition2, ViewportPosition2);
UWidgetBlueprintLibrary::DrawLine(InContext, ViewportPosition, ViewportPosition2);
}