StyleBoxTexture that doesn't distort the edges?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By exuin

I’ve tried using StyleBoxTextures in my theme but they stretch the borders even with the margins set inward, especially with panels that are in different shapes than the base texture. Is there a way to get them to only stretch the top and bottom borders to the horizontally and to only stretch the left and right borders vertically? That would preserve the border width.

:bust_in_silhouette: Reply From: exuin

As it turns out, that’s just how nine patch rects work. If I don’t want my image to stretch, I need to create the image at the size intended.

:bust_in_silhouette: Reply From: mattkg0

No, you should be able to create your 9 patch image and use it for pretty much any size without it appearing distorted. I ran into the same problem as you trying to theme my Buttons with a StyleBoxTexture.

Double check your Margin values for the StyleBoxTexture, generally you want those to match the “corners” for your 9 patch image so the vertical and horizontal edges tile correctly.

If that doesn’t help, try it with a NinePatchRect first to see if you can get it to appear correctly. The property to play with there is the Patch Margin.

I hope that helps.