godotengine / godotengine/godot

Setting TextureRect.texture does not update the node's size in the same frame.

Open
#89,258 4 comments 0 reactions 0 assignees View on GitHub
discussion documentation topic:gui
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Godot 4.3.dev4.official

### System information

Pop!_OS 22.04 LTS - 64 Bits

### Issue description

Doing `TextureRect.texture = load("path.image")` does not update the node's size until the next frame. Which makes things like replacing the texture in the same call behave unexpectedly if you are assuming that doing `TextureRect.texture = null` resets the `size` to zero.

Workaround is to wait for the next frame for it to properly reset the `size`.

### Steps to reproduce

Reproducible in the MRP provided.

### Minimal reproduction project (MRP)

[project.zip](https://github.com/godotengine/godot/files/14528477/project.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached project.zip and reproduce the TextureRect.texture assignment behavior described in the issue. Investigate why assigning null or another texture leaves the node size unchanged until the next frame. Done means the node size reflects the new texture within the same frame, with the reproduction project confirming the behavior.

Written by the indexing model from the issue text.

Assessment

Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.