PngNix
EN TR

Guides · 2026-11-21

9-Slice Scaling for Game UI Frames and Panels

How to stretch decorated UI frames and window panels to any size without distorting the corners, with setup steps for Unity and Godot.

Decorated frames and window panels rarely have the exact size your layout needs. If you simply stretch the image, the ornate corners turn into ovals and the border gets thick on one side and thin on the other. 9-slice scaling (also called 9-patch) solves this, and it is supported by every major engine.

1. How 9-slice works

You draw four guide lines on the image: two vertical and two horizontal. They split it into nine parts:

  • 4 corners – never stretched, so the decoration keeps its shape;
  • 4 edges – stretched in one direction only (top and bottom horizontally, left and right vertically);
  • 1 centre – stretched in both directions, or left empty.

The result is a panel that can become a small tooltip or a full-screen inventory using the same 512 px file.

2. Choosing the border values

  • Place each guide line just inside the decorated corner, where the border becomes a plain repeating strip.
  • Keep left/right and top/bottom values equal when the art is symmetrical; it makes the panel easier to reuse.
  • If an edge has a centred ornament (a gem or a crest in the middle of the top border), 9-slice will stretch it. Either choose a frame without a middle ornament for that use, or place the ornament as a separate image on top.
  • The minimum size of the panel is the sum of the two corner widths. Smaller than that, the corners overlap.

3. Unity

  • Import the PNG as Sprite (2D and UI) and open the Sprite Editor (install the 2D Sprite package if it is missing).
  • Drag the green border handles, or type the values into Border (L, T, R, B), and click Apply.
  • On the UI Image component set Image Type to Sliced. Turn off Fill Center if you want the inside to stay transparent.
  • Use Pixels Per Unit Multiplier to make the border thinner or thicker without editing the art.

4. Godot 4

  • Add a NinePatchRect node and assign the PNG to Texture.
  • Set Patch Margin left, top, right and bottom to your border values.
  • Use Axis Stretch Stretch for smooth edges, or Tile / Tile Fit if the edge has a repeating pattern such as rivets or chain links.
  • Uncheck Draw Center to keep the middle transparent. For theme-wide panels, a StyleBoxTexture with the same margins can be used on Panel and Button nodes.

5. Buttons, bars and windows

  • Buttons: slice them the same way, then create hover and pressed states with a colour tint or a 2–4 % scale change instead of separate images.
  • Hotbars: long bars are usually sliced only horizontally; the slots in the middle can be tiled.
  • Windows: keep a fixed inner padding (for example 24 px) between the frame and your content so text never touches the border.

6. Checklist

  • Border lines inside the corner decoration
  • No important ornament on a stretched edge
  • Centre fill off when the panel should be see-through
  • Panel never smaller than the two corners together

Related categories

  • Frames
  • Game UI Kit

More guides

  • How to Use Transparent PNG Icons in Unity and Godot
  • Using Animated Stickers and Emojis on Discord, Streams and Websites
  • Game Icon Readability: Size, Colour and Consistency Checklist
© 2026 PngNix
Privacy Cookies Terms Guides Tools About Contact
Free for personal and commercial game projects. No resale or redistribution.

Cookies. We use cookies that are necessary for the site to work. With your permission we also allow third-party cookies to show ads. You can change this at any time. Learn more