Godot Version
4.3 stable
Question
Picture 1
When program is running,
change the value of v1 in inspector,
and the value in program is correct.
Picture2
When program is running,
press input key to increase the value of v1,
v1 is 6.
But in the inspector, the value of v1 is still 3.
How can I sync the value between program and inspector?
@tool
extends Node2D
@onready var label: Label = $Label
var v1 : int = 1:
get: return v1
set(value):
v1 = value
update_ui()
notify_property_list_changed()
func _ready() -> void:
update_ui()
func _input(event: InputEvent) -> void:
if Input.is_action_just_pressed("1"):
v1 +=1
notify_property_list_changed()
# I want to refresh the data value of v1 in the inspector
func update_ui():
if not is_inside_tree():
await ready
label.text = str(v1)
func _get_property_list():
var plist = []
plist.append({
"name" : "v1",
"type" : TYPE_INT,
})
return plist