+2 votes

Wouldn't be useful having the option to flip a textureRect ?
Since it is a Control Node and it can be very useful in creating UI, but there is no way at all to flip the Node (unless you use rect_scale , but this does not work when inside Containers like HBOX or VBOX)

What do you guys think about it?

asked Sep 1, 2018 in Engine by salvob (27 points)

2 Answers

+1 vote

It would be handy, you could make it work by parenting the TextureRect to a Control with a script like this.

extends Control

export var flipped_h = false
export var flipped_v = false

func _ready():
    if flipped_h:
        $TextureRect.rect_scale.y *= -1
        $TextureRect.rect_position.y = $TextureRect.rect_size.y
    if flipped_v:
        $TextureRect.rect_scale.x = -1
        $TextureRect.rect_position.x = $TextureRect.rect_size.x
answered Oct 23, 2018 by flurick (886 points)

Thank you, i didn't know that scale -1 would flip the texture.

0 votes

Another possibility would be to get the image from the texture which has the flip_x and flip_y methods.
Then you can create a new ImageTexture from the flipped version and set that as texture for the texture_rect.

answered Dec 20, 2019 by sleepprogger (116 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.