godotengine / godotengine/godot

Incoherent control anchor / size warning

Open
#113,205 2 comments 9 reactions 0 assignees View on GitHub
bug topic:gui usability
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

4.6 dev4

### System information

N/A

### Issue description

The control nodes display a warning when the size is changed even though the anchors are not equal:
```
update_anchor(): Nodes with non-equal opposite anchors will have their size overridden after _ready().
If you want to set size, change the anchors or consider using set_deferred().
```

The problem is that it doesn't differentiate between the X and Y axes. If I write:
```
anchor_top = 0
anchor_bottom = 1
size.x = 10
```
I get the warning even though the code works correctly, and the correction suggested by the error (using set_deferred()) did not work in the cases where I encountered this warning.

I don't know if there's a simple way to fix this, I haven't found a practical way to avoid this warning, and it doesn't seem possible to ignore it with "@warning_ignore"

The warning in the Godot source code:
https://github.com/godotengine/godot/blob/bd2ca13c6f3a5198eac035c855dcd1759e077313/scene/gui/control.cpp#L1479
This Reddit post seems to be discussing a similar problem that could be related:
https://www.reddit.com/r/godot/comments/1m0g4pk/is_there_a_way_to_make_this_warning_go_away/

### Steps to reproduce

A scene with a control node containing this code:
```
extends Control

func _ready():
anchor_top = 0
anchor_bottom = 1
size.x = 50
```

### Minimal reproduction project (MRP)

N/A

Contributor guide

Open the contributing guide

Research direction

Start at scene/gui/control.cpp around update_anchor() line 1479 and reproduce the warning with the provided Control script. Trace how opposite anchors and size changes are checked on each axis. Done means the warning appears only when the changed size is affected by the relevant non-equal anchors, with regression coverage for the X-only example.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, godot
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.