Topic was automatically imported from the old Question2Answer platform.
Asked By
vonflyhighace2
Old Version
Published before Godot 3 was released.
I’m trying to build a list of resolution modes using OS.get_fullscreen_mode_list() but it always return an empty array. Don’t know what I’m doing wrong, maybe someone can enlighten me. Thanks
I recently solved this problem. It’s not the system solution, but it works.
I created a global script. In it I have declared an array which contains a list of screen resolutions which I decided to support (maybe not all of these resolutions are supported on the user’s PC). This is a “etalon” list which will be used in the final selection of screen resolutions. I have it looks like this:
var PoddergivaemieRazresheniya=[Vector2(1366,768),
Vector2(1600,900),
Vector2(1920,1080),
Vector2(2560,1440),
Vector2(3200,1800),
Vector2(3840,2160),
Vector2(4096,2160)]
As you can see I was limited to standard screen resolutions “16*9”. You can extend it at its discretion.
Next, I declare another array:
var Razresheniya=[Vector2(1280,720)]
In this array will be stored screen resolutions are supported on the end user PC. And the element which is already in the list is the minimum screen resolution (it is the set to default “Project settings”).
It remains only to produce the sample:
func _ready():
var n=0
var vV=Vector2(0,0)
var vRE=Vector2(0,0)
vRE=OS.get_screen_size(OS.get_current_screen()) # Find out the system resolution to active screen
# Performed the sample
for n in range(PoddergivaemieRazresheniya.size()-1):
vV=PoddergivaemieRazresheniya[n]
if vRE[0]>=vV[0]:
if vRE[1]>=vV[1]:
Razresheniya.resize(Razresheniya.size()+1)
Razresheniya[Razresheniya.size()-1]=vV
pass