0 votes

I am currently trying to automate an update to my child label to be runned in the editor, however it always returns to it's default value after I click on another node, I'ma show as it's easier than explaining:

The node structure of the scene is

World node:
    Node2D -> Box
    Node2D -> Box1

BOX, Node2D code:

extends Node2D

export(String) var ItemID = "NOONE" setget UpdateMyLabel

func _ready():

func UpdateMyLabel(newName):
    if Engine.editor_hint:

I duplicate the Box a fewer times, select the first and type in the exported var, it works, the label get's renamed, however when I select another box, the ItemID on the previous node get's reset to "NOONE", but the label doesn't update, and if I print it really changed to the default value: NOONE. Why is that?

There's not anything more running in the background, I recreated this with a clean scene.

asked Mar 31 in Engine by The_Black_Chess_King (265 points)

1 Answer

+2 votes
Best answer

You're gonna have to update ItemID in the set function UpdateMyLabel, it's not gonna update itself. Add ItemID = newName on the last line of the set function.

func UpdateMyLabel(newName):
    if Engine.editor_hint:
    ItemID = newName
answered Apr 1 by Mike Trevor (189 points)
selected Apr 1 by The_Black_Chess_King
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.