Godot Version
4.2.1
Question
I need to modify the project via code but that’s not my problem. The problem is that these settings don’t exist now, how can I create them via code?
4.2.1
I need to modify the project via code but that’s not my problem. The problem is that these settings don’t exist now, how can I create them via code?
Can you provide a more concrete example of a thing you are wanting to do? Can you provide examples of what you can already do as well?
I know I can access the project settings like this:
ProjectSetting.get_setting(Path)
and ProjectSetting.set_setting(Path, Value)
It is also possible to add settings to the editor settings in the editor and use them in this way as well.
But I need to add some settings to the project settings through the code, in this case set_setting()
doesn’t create a new setting.
I would like to know what kind of additional setting fields you would want to introduce to the system file of Godot?
Isn’t it sufficient to create a custom .json file that has extended game-specific options for your game?
Or do you want to create a custom editor plugin that is able to change project setting values and expand upon existing ones?
I have a few variables that I need to view and change from Project > Project Settings.
I know it might sound a little confusing, because I’m not making a game, I’m building a plugin
The closest use-case i could find is to create an override.cfg
file which has all the extra variables defined that isn’t defined yet in the Project Settings and placing the file into your project’s root folder but this is in connection to gamedev. For plugindev, I am sadly not helpful.
Maybe create a plugin and within that plugin you extend the ProjectSetting class and add new functionality and variables into it.
Or maybe make use of ProjectSettings.add_property_info(property_info)
as documented here: ProjectSettings — Godot Engine (stable) documentation in English
I’ve tried it before but it doesn’t work
Eventually, I might have to ask the user to manually add a setting and then change it through the code, and that’s how it works.
But I’m trying to get away with it, as it will make the installation process too difficult.
The Godot Jolt plugin adds its owm settings. Perhaps look at how that project manages to do it?
https://github.com/godot-jolt/godot-jolt/blob/master/docs/settings.md
All of the “jolt” settings get added.
I spent a lot of time on it but I finally succeeded. ProjectSettings.set() works but only creates new values for values like “Customize/My Setting1”, for more internal ones like “Customize/Names/Player1” that variable must already exist. Thanks for your tips! This is apparently a bug.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.