I have a umg hud setup for my minimap.
Map is rendered to Image Mini Map, some sprites above it and Canvas Npc for Npc tokens and their visiblilit triangles. I am placing them dynamically at runtime from C++ code.
And here is the image i got in game
You can see I have two visibility sector sprites cut from the wrong side. Looks like they are cut before they are rotates. Is there option how I can fix this behaviour?
My code for visiblility sprites creation.
UTexture2D *FovTexture = Npc->NpcAIComponent->LookHalfSector > 50 ? NpcFov120Material : NpcFov60Material;
VisibilityImage = NewObject<UImage>();
VisibilityImage->Brush.SetResourceObject(FovTexture);
NpcPanel->AddChild(VisibilityImage);
NpcCanvasSlot = Cast<UCanvasPanelSlot>(VisibilityImage->Slot);
NpcCanvasSlot->SetSize(FVector2D(FovTexture->GetSizeX(), FovTexture->GetSizeY()));
NpcCanvasSlot->SetAlignment(FVector2D(0.5f, 1.0f));
NpcCanvasSlot->SetAnchors(FAnchors(0.5f, 0.5f));
VisibilityImage->SetRenderTransformPivot(FVector2D(0.5f, 1.0f));
And code for their position setup and rotation.
if (VisibilityImage != nullptr) {
VisibilityImage->SetVisibility(ESlateVisibility::Visible);
NpcCanvasSlot = Cast<UCanvasPanelSlot>(VisibilityImage->Slot);
NpcCanvasSlot->SetPosition(NpcPanelCanvasSize * MinimapDirection);
VisibilityImage->SetRenderAngle((1 - Angle) * 360.f + Npc->GetActorRotation().Yaw + 90);
VisibilityImage->Brush.TintColor = FSlateColor(FLinearColor(1, 1, 1, 1 - MinimapDistanceSq));
}
Don’t think there are errors there, but just for the info. they are positioned and rotated correctly I think.
It is some bug in sprites cutting logic in umg?
They are also wrongly cut in UMG editor preview.
Any ideas how I can overcome this? Or place where I should dig in UE source code?