+2 votes

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

in Engine by (881 points)

2 Answers

+2 votes
Best answer

Most project settings are only read when the project starts. This means changing them at run-time won't apply any visible changes.
https://docs.godotengine.org/en/stable/classes/class_projectsettings.html#class-projectsettings-method-set-setting

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:
https://docs.godotengine.org/en/stable/tutorials/viewports/viewports.html

by (2,834 points)
selected by
+1 vote

You can use:

OS.set_screen_orientation(value)
by (211 points)
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.