How to change project settings with code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Help me please

Hi everyone!
In my project I have a portrait mode game while in one scene I want to make it in landscape made please tell me how to change project settings in code

:bust_in_silhouette: Reply From: timothybrentwood

Most project settings are only read when the project starts. This means changing them at run-time won’t apply any visible changes.

ProjectSettings.set_setting("display/window/handheld/orientation", "portrait")
ProjectSettings.save()

Restart the game and see the orientation has changed. Note that save_custom("filename") is the proper way to do this.

You might be able to accomplish what you’re trying to do using a Viewport:

is there any way to switch renderer inside the game ?

sanket | 2023-05-16 10:44

:bust_in_silhouette: Reply From: luislodosm

You can use:

OS.set_screen_orientation(value)

is there any way to switch renderer inside the game ?

sanket | 2023-05-16 10:43

I see that this was available in OS for Godot 2.1, but hasn’t been in the OS since at least Godot 3.1. Was this functionality moved somewhere else, or is it simply not available as of Godot 4.2??

In case someone else comes across this topic and is wondering where OS.set_screen_orientation went, I just found out it was moved to DisplayServer.screen_set_orientation. I guess the change in the wording of the function was why I couldn’t find anything in the docs :frowning:

1 Like