+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?

in Engine by (27 points)

3 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
by (911 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.

by (118 points)
0 votes

Another option is to set the pivot to center and then rotate rect 180 degrees.
See in the image below:

Godot flip texture_rect
by (20 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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.