Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit a signal when a setting is changed in the Project Settings #2155

Closed
andy-noisyduck opened this issue Jan 20, 2021 · 4 comments
Closed

Comments

@andy-noisyduck
Copy link

Describe the project you are working on

Plugin

Describe the problem or limitation you are having in your project

There's no way for a plugin to know if a project's settings have been changed. Currently the best way to use project settings is to re-fetch them at the point the setting is used. It's not feasible to do this for all types of settings, for example, a toggle for an operation that happens in the background. In my plugins I'm getting around this by polling settings on a timer, but that solution feels a bit ugly.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

An extra signal called emitted through EditorPlugin (?) called settings_changed. Optionally we could include the key of the setting that was changed, but having the signal at all would be a great start.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

myPlugin.connect("settings_changed", self, "on_settings_changed")

If this enhancement will not be used often, can it be worked around with a few lines of script?

You could work around this by implementing polling yourself. It's reasonably trivial, but this very much feels like functionality that should already be there. We already have methods for plugins to get and set the settings.

Is there a reason why this should be core and not an add-on in the asset library?

Fixes a gap in existing core functionality.

@me2beats
Copy link

What about ProjectSettings.settings_changed signal (instead of EditorPlugin one)?
I also think some info on "what setting was changed" would be useful as well, so it could be setting_changed instead of settings_changed:
String ProjectSetings.setting_changed()
This would allow to do something like:

func on_setting_changed(setting:String):
    ...

@Calinou Calinou changed the title Signal for changes in project settings Emit a signal when a setting is changed in the Project Settings Jan 20, 2021
@YuriSizov
Copy link
Contributor

Definitely should be a signal on the ProjectSettings singleton. It is exposed, no reason not to use it.

@YuriSizov
Copy link
Contributor

Apparently, godotengine/godot#45956 added a project_settings_changed signal to EditorPlugin API. Should probably be manually backported to 3.x, because I don't think that this PR itself can be backported.

@akien-mga
Copy link
Member

Implemented by godotengine/godot#53296.

@akien-mga akien-mga added this to the 3.x milestone Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants