#How to _draw over TextureRect?

10 messages · Page 1 of 1 (latest)

polar kelp
#

Im trying to make app where at some point user can choose picture and select region on image. I use TextureRect to draw image, and use _draw() to draw rectangle. It works on empty viewport, but any object is drawn on top of rectangle. How can i change order of things being drawn on viewport or something like that?

torn fulcrum
#

I would suppose your app is in 2D, make sure the Z index or your TextureRect is higher than the rest of the nodes Z index, you will find a Z index inside every canvas item (all Node2D inherits from canvas item) under the "ordering" group in the inspector

polar kelp
#

Didnt work

torn fulcrum
#

Try checking the "Top Level" property inside the visibility group

polar kelp
#

still nothing

torn fulcrum
#

weird

polar kelp
#

okay, i found fix

#

i rewrote _draw function for TextureRect instead of parent node, so it draws image first and rectangle after. Weird its the only thing that helped

torn fulcrum
#

ohh, i though u were having problems with the rest of the scene, but yeah, if you use the _draw function manually, u should draw the elements in the order you want them to appear

#

Take into account that TextureRect has a "Texture" property, so u dont need to draw the image by hand