|
|
|
 |
Reply From: |
Calinou |
As of Godot 3.0, you can just set OS.window_fullscreen
to true
in any script to enable fullscreen – no need to deal with the project settings manually. It will behave the same way as the project setting does.
Tip: If you want to toggle fullscreen, you can avoid using an if
condition by setting OS.window_fullscreen
to its inverted value:
if event.is_action_pressed("toggle_fullscreen"):
OS.window_fullscreen = !OS.window_fullscreen
Thanks. That inversion trick is very cool. Didn’t know about it.
Diet Estus | 2018-05-12 23:52
Thank You, this is a great answer!
I had to change it to the following, however:
if Input.is_action_just_pressed("toggle_fullscreen"):
OS.window_fullscreen = !OS.window_fullscreen
The godot version I use is 3.0.2
All the best
greymalkin | 2018-08-04 14:34
In godot 3.2, you must use
OS.set_window_fullscreen(!OS.window_fullscreen)
as OS.window_fullscreen
is read-only
cheers
frankiezafe | 2021-01-31 00:28
OS.window_fullscreen = !OS.window_fullscreen
works in v3.3.2.stable.official for me
Mariothedog | 2021-08-24 13:29
Literally none of these solutions are working for me in version 3.4.3.stable, I have absolutely no idea what I could be doing wrong 
This is just inside my Player script as I wasn’t sure where else to put it. Other keybindings work fine in other functions within this script. I have the button set as the F key in Project settings just like the other keybindings.
func _ready():
animationTree.active = true
swordHitbox.knockback_vector = Vector2.DOWN
stats.connect("current_health_zero", self, "queue_free")
OS.window_fullscreen = true
if Input.is_action_just_pressed("toggle_fullscreen"):
OS.window_fullscreen = !OS.window_fullscreen
What in the world am I doing wrong?? I’ve tried it without the OS.window fullscreen = true line, I’ve tried it with the Fullscreen checkbox checked and unchecked in the project settings, I’ve tried using different keybindings, and I’ve tried all of the above solutions.
PIZZA_ALERT | 2022-03-07 07:40
_ready()
is only called once, when the node enters the scene tree and is therefore not suitable for checking input events.
IsThisTheFuture | 2022-03-07 23:22