• Godot Help
  • How do you make a 9PatchRect into a button?

Seriously I've looked this up every possible way and there's virtually no answers or only deprecated ones. I simply want a button that is 9-sliced. That's is. How do I do that without it being overly complicated? Can I not just apply a texture to a button and set sprite margins for the button itself? If not then why not because I feel like 9-sliced UI is probably the most common way anyone sets up UI to begin with. I've got a 15x15 image on a texture button so can I just tell it the border margins are 5 pixels in from each side or no? I'm transitioning from unity given the recent bs with them but so far Godot is really complicated I find.

    NinePatchRect can normally receive gui input.

    disgrandpa If not then why not because I feel like 9-sliced UI is probably the most common way anyone sets up UI to begin with.

    I've never done that with a button or seen anyone ask about it. It doesn't look like there's a way to apply a nine-patch to a stock button, but as xyz says, the nine-patch will still respond to clicks if you set it up to. You'd probably have to code any color changes or animation in response to input. I say probably, because there may be a way to use a theme to do that. I'm still trying to work my way into themes.

      duane because there may be a way to use a theme to do that.

      I can't be bothered to open up godot right now to double check but I do want to say that should be indeed the case since a 9 patch model is the only minimal way to really build a scalable bitmap based button. That is to say, it's probably well worth OP's time following up on this idea.

      Yes you can make 9 sliced buttons in Godot. The way I did it in my project is by creating a theme for the whole GUI. If you go down that route (a bit more work but worth it for many reasons): when defining a button, simply add a new resource of type "New Atlas Texture" and define the margins, how you want the button to behave when stretched etc. Have you tried looking here?