#How do I draw a nine patch in C#?
1 messages · Page 1 of 1 (latest)
This doesn't really depend on language. You can either use the NinePatchRect node, or use a StyleBoxTexture on any Control node that supports it
I need to draw it from a node2d or control
What do you mean "draw" it? Why can't you use one of those two options?
If you're just talking about using draw functions, then you can do that but there's no built-in method for it. You'd just have to use draw_texture_rect_region and make the logic yourself using multiple calls to that function
can you provide a example? I have never drawn nine patches before
If you're not sure how, I highly recommend one of the other two options
A NinePatchRect node is the easiest way to do this
I am building my own widget node that suits my needs NinePatchRect is not a option
Then you'll have to figure it out yourself
It's a lot of code, I don't really want to write it for you
How about you give it a try and then return if you can't get it to work?
Also, seriously consider whether you can actually use NinePatchRect or StyleBoxTexture. It will be much easier
Maybe if you can explain what you're trying to accomplish?
I have already tried
the scene tree makes the whole process alot more complex not to mention I can't convert a scene into a custom type
Well if you're not willing to use one of the easy options, and you're not willing to try to write it yourself, and you're not willing to describe what you're trying to do, then I'm not sure there's anything else I can help you with, sorry
how is another node easier then just drawing it?
Because it does it for you?
yes but it requires me to delete it and to make sure it's in the scene and it also requires me to hide it so it doesn't get removed with get_child
None of that has anything to do with a 9-patch
You would still need a node to draw it with, so these issues will exist either way
yes I have one but it doesn't need to manage a child
it's part of the script instead of the scene
which scales a hell of alot better
Keep in mind I have no context about what you're trying to do
I am making a widget node that handles focus themes, sounds and everything I would expect the control node would do but doesn't
it also handles pressing and toggling so it's kinda like a button
Just let it use a StyleBox