When using sprites from paper2D I need to scale them correctly, so I need the size of the sprite in the atlas to do so. The function in c++ in GetResourceSize() and for some mysterious reason, it can be used only in the editor. I need this size in order to get a ratio and scale sprite accordingly.
I debugged sprite, found out there is a vector of BakedRednderData, that have values half of the original sprite size, so I came out with this solution:
float USpriteFunctionLibrary::GetImageRatio(UPaperSprite * Sprite)
{
if (Sprite)
{
if (Sprite->BakedRenderData.Num() > 0)
{
FVector2D size(Sprite->BakedRenderData[0].X, Sprite->BakedRenderData[0].Y);
return FMath::Abs(size.Y / size.X);
}
}
return 1.f;
}
And I can get a source image size by multiplying size vector with roughly 5 pixels error, which is not perfected, but better than nothing.
Does anyone know a better way to do this?