+1 vote

How do you get notification that the contents of a Dictionary instance changed? Specifically, in a tool script where the user edits the Dictionary in the Inspector?

It's possible to use setget on a Dictonary variable and implement the setter function to emit a signal, but that only captures when the Dictionary variable is set to a whole Dictionary instance. It does not capture when the contents of the Dictionary are modified.

in Engine by (66 points)

It doesn't look like there are signals for when Dictionaries are changed. So it looks like you'll have to do it some other way.

One way to monitor a Dictionary is to check how many keys the Dictionary has. A change in the number of keys indicates that a change has happened in the entire Dictionary. If you only need to monitor a few keys, then check the size of the values. If the values changed in size, then the Dictionary changed. If you really need to keep track of them, check the hashes of the values. If they change, then the Dictionary has changed.

Please log in or register to answer this question.

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.