Godot Version
4.7.1
Question
Hi all! I’ve got this question up on Reddit already, but the code is changed enough and the problem become perplexing enough that I thought I’d bring it over here.
I’m making a plugin and want to add settings to the Project Settings. plugin.cfg points to testing.gd, which looks like this:
@tool
extends EditorPlugin
func _enter_tree() -> void:
_check_settings()
func _check_settings() -> void:
var the_name = "plugins/testing/test_value"
if !ProjectSettings.has_setting(the_name):
ProjectSettings.set_setting(the_name, 0)
ProjectSettings.set_initial_value(the_name, 0)
ProjectSettings.set_as_basic(the_name, true)
ProjectSettings.add_property_info(
{
"name" : the_name,
"type" : TYPE_INT,
"hint" : PropertyHint.PROPERTY_HINT_ENUM,
"hint_string" : "Blue,Red,Green,Yellow,White"
})
ProjectSettings.save() # does not seem to actually do anything, but added on advice
After activating the plugin and checking the Project Settings window, I can see the Plugins/Testing category with the Test Value option, as a basic setting and listing the values correctly from the enum property hint. I leave it alone for the moment.
I then have a simple Control scene that runs a print call from _ready():
print(ProjectSettings.get_setting("plugins/testing/test_value"))
It prints <null>
Checking the project.godot file, there is no added [plugins] category at all, much less testing/test_value=0
I go back into the editor, go to Project Settings, find my setting, change the value, and close Project Settings. Running my scene, it prints the correct value. Checking project.godot, the setting is now there with the correct value.
What do?