I’m creating a few tool nodes that can be configured extensively, and because of this, I’d like them to automatically update their name property when any changes are made to said nodes.
For example, in my MapGenerator addon, I have a node that repeats children nodes x amount of times. The goal is to apply the repitition count to the name of the node, something like:
The issue I’m having, is how to actually trigger the _on_property_changed() function I’ve defined here.
I know I can use setters, but I’d like to stay away from typing a billion different functions for simply triggering this reaction… there has to be another way, right?
I’ve also considered using _get_configuration_warnings(), but this method seems to only get called when things like scene tree position change.
But to be serious. You can use a setter in your export variable and when a value is set. you make the variable store the value and call _on_property_changed() which there, it will change it’s name
@tool
extends Node
@export var repetition_count: int:
set(value):
repetition_count = value
_on_property_changed()
func _on_property_changed() -> void:
name = "Repeater_%sx" % repetition_count
Hey! This is actually what I was doing before, but I’m trying to stay away from this approach so that I don’t have to create a bunch of setters for every property of my nodes