Quick answer: The preset dropdown is computed from the underlying anchor + offset values. If they drift, the preset shows as “Custom” on reload. Apply presets via set_anchors_and_offsets_preset() for clean storage.

You set a Control to “Full Rect” preset in the editor. Save the scene, reload, and the preset reverts to “Custom”. The element looks right, but the dropdown shows custom — and a code generator that reads the preset name fails to detect the intended layout.

How Anchor Presets Actually Work

The preset dropdown in the Inspector is not a serialized property. It’s a computed display based on the four anchor_* values and four offset_* values. A “Full Rect” preset means:

anchor_left   = 0.0
anchor_right  = 1.0
anchor_top    = 0.0
anchor_bottom = 1.0
offset_left   = 0.0
offset_right  = 0.0
offset_top    = 0.0
offset_bottom = 0.0

If any of those eight values drifts — for example, you dragged the corner by a pixel during editing — the preset displayed becomes “Custom”. Save and reload: the offsets persist; the dropdown remains custom.

Fix 1: Apply Preset via Script at _Ready

extends Control

func _ready():
    set_anchors_and_offsets_preset(PRESET_FULL_RECT)

This resets all eight properties to the canonical preset values regardless of what the editor saved. Use when you specifically want a node to always behave as a known preset at runtime.

Fix 2: Clean Up the Saved .tscn

For scene-driven layouts, open the .tscn file in a text editor and replace drifting values with the canonical preset constants. For PRESET_FULL_RECT on a default Control, the entire [node] block contains no anchor/offset overrides — the inherited defaults are exactly the preset values.

Or in the editor, click the preset dropdown to re-apply “Full Rect”. The Inspector writes canonical values back to the saved scene.

Fix 3: keep_offsets for Preserving Layout

When swapping presets at runtime without moving the visual, pass keep_offsets=true:

set_anchors_and_offsets_preset(PRESET_CENTER, PRESET_MODE_KEEP_SIZE, 0)

The anchor ratios change but the offsets are recomputed to keep the visual rect identical. Useful for reflowing UI between screen sizes.

Verifying

Compare the .tscn diff before and after reload. Drift values like offset_right = -1.0 or anchor_left = 0.001 reveal the cause. After applying script-based preset reset, save and confirm the scene file no longer contains drifting values.

“The preset is what you see, not what’s saved. Reset via script for runtime certainty, or click the preset again in the editor.”

Drag-to-resize in the 2D editor can introduce sub-pixel anchor drift — click your preset once after any visual adjustment to snap it back to canonical values.