![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | xananax |
I’m getting stumped about setting children properties from getters in tool
s. Here’s a piece of code:
export(String) var title setget _set_title, _get_title
func _set_title(_value: String) -> void:
title_label.text = _value
func _get_title() -> String:
return title_label.text
setting the title in the inspector gives you:
Invalid set index 'text' (on base: 'Nil') with value of type 'String'.
So, you do this:
func _set_title(_value: String) -> void:
if not is_inside_tree(): yield(self, 'ready')
title_label.text = _value
This works, but then, each time you save the scene, you get the same message.
So you do:
func _set_title(_value: String) -> void:
if not is_inside_tree(): yield(self, 'ready')
if not title_label: return
title_label.text = _value
And this works, but now when running the scene, I get
resume: Resumed function '_set_title()' after yield, but class instance is gone.
This is all very confusing, and seems like a lot of acrobatics for what boils down to accessing children’s properties from a scene that needs to be instanced a lot.
To note: everything technically works, as in, the scene runs and does what it should. But since this is supposed to be released as a plugin, the error is annoying.