godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.36k stars 21.25k forks source link

_set() with @tool does not work when property is edited from 2D/3D tab #87355

Open etherealxx opened 10 months ago

etherealxx commented 10 months ago

Tested versions

System information

Godot v4.2.1.stable - Windows 10.0.19045 - GLES3 (Compatibility) - ANGLE (AMD, AMD Radeon(TM) R3 Graphics (0x000098E4) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.20906.6) () - AMD A4-9125 RADEON R3, 4 COMPUTE CORES 2C+2G (2 Threads)

Issue description

On the provided MRP, there are several nodes for example. The Panel one. It has this code.

@tool
extends Panel

func _set(property, value):
    if property == "size":
        size = value
        print("Resized to %v" % value)
        return true
    return false

Now when you try to edit the size of said Panel with Inspector (Layout > Transform > Size), either by typing the value then press Enter, or dragging the number left and right, you will notice there are several text getting printed, which means the code runs fine.

However, when you resize via the 2D scene editor, by clicking the panel once, until there's orange outline, then dragging the outline to resize the Panel, there will be no print out at all, which means the code doesn't run.

It's also a the case with the Sprite2D and Marker3D example.

Steps to reproduce

You can try and test with other node like the Sprite2D and Marker3D.

Minimal reproduction project (MRP)

setget_test.zip

KoBeWi commented 9 months ago

Manipulation via gizmos bypass the usual setters, they go through a separate method.

addmix commented 1 week ago

This seems related:

_set() does not run with this assignment: current = true However, _set() does run with this assignment: self.current = true

This logic carries on, if you reference a variable, get_node("MyNode").current = true, _set() does run. This is an inconsistency that seems unnatural to me.