+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 (942 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 (3,884 points)
selected by
0 votes

You can use:

OS.set_screen_orientation(value)
by (318 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 Frequently asked questions and 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 [email protected] with your username.