My game is almost finished, but bugs remain: Bug number 4 - Solved


(Helgard de Barros) #1

My play testers have found a bug.

If you start a game and go to the options menu, you can select your screen resolution. It shows a default resolution of 1920x1080.

The blox set the display resolution on the menu.

The player can set the resolution using the arrows

And then he can apply the changes

The bug is that if the player selects a lower resolution, say for example 1600x1024, and clicks “apply”, then the option to go back to a higher resolution disappears. You can select any resolution lower than the one on which you clicked apply, but any resolution higher than the one you selected and clicked “Apply” on no longer shows.

Any idea where I should be looking or why this is happening?


(Alien) #2

not sure on your issue… but…

I have always found the res part to be not my preference using arrows and use a drop down menu instead. the attached script will get the list of resolutions and place them in your drop down menu for selection. if your interested…

ScreenResolutions.cs (893 Bytes)


(Helgard de Barros) #3

Mmmm, I had a look at it, but to be totally honest, I have no idea what to do with it, lol.


(Alien) #4

Create a drop down menu. attach this script to the dropdown menu.

I’m using Textmesh pro dropdown, so if your using regular text dropdown, you will need to modify it.

here is what it looks like

Capture2


(Helgard de Barros) #5

What do I do to fix this line if I am not using Textmesh

dropdownMenu.options.Add(new TMPro.TMP_Dropdown.OptionData(dropdownMenu.options[i].text));


(Alien) #6

you would need to replace the public var from a TMP Dropdown, to a regular Unity dropdown.

i will see if i can get you something later after work.


(Alien) #7

i think this version will work. i basically remarked out the TMP lines, and made the Unity dropdown instead.

ScreenResolutions.cs (1.0 KB)


(Helgard de Barros) #8

Mmmm, so I replaced the arrow selection with the drop down, and it is giving me a lot of funky effects. If I select the options screen, it immediately goes into windowed mode. I have to uncheck the full screen checkmark, check it again and apply, to get it to full screen.

And selecting a different resolution doesn’t apply when I click apply. I will have to go through the code I have used a few more times.

Also, it is showing each resolution more than once, as in the picture.

Desktop


(Alien) #9

I’m guessing that the duplicate results are based on your video card supporting resolutions at different frequencies.
not sure on the fullscreen…

my guess is that it’s this line. Change the false, to true (or setup a variable to detect if the screen is fullscreen or not, then set it appropriately.

dropdownMenu.onValueChanged.AddListener(delegate { Screen.SetResolution(resolutions[dropdownMenu.value].width, resolutions[dropdownMenu.value].height, false); });

sorry I’m kinda guessing, the addListerner stuff is a bit new to me…


(Leslie Young) #10

Yes, the duplicates are because of that. It should have shown something like 720 x 480 @ 60Hz and perhaps 720 x 480 @ 30Hz, etc

Changing this line
dropdownMenu.options[i].text = ResToString(resolutions[i]);

to this, should show Hz if I am not mistaken.

dropdownMenu.options[i].text = resolutions[i].ToString();


(Helgard de Barros) #11

Cool, thanks!

@Alien - OK, it is no longer switching to windowed mode.

@leslie - It is now showing the frequency as well.

But, does this script change and APPLY the resolution? I have this on my “Apply” button:

If I use the drop down and change the resolution it changes, but when I click apply it reverts back to 1920 x 1080. Should I just remove that command from the Apply button?


(Alien) #12

i used the apply on the UI button when exiting that UI Panel and it works for me.


(Helgard de Barros) #13

If I change the resolution and click the back button, then the resolution stays applied.

If I click the “apply” button, it reverts to 1920 x 1080, but if I then go back to the options menu, it displays the new resolution I chose, even though it is actually on 1920 x 1080.

But if I take out the Apply Resolution block on my apply changes, then when I click apply it should only apply my fullscreen settings and GFX settings.

So I am going to try that. Takes three hours to do a build to test the changes every time I make a change…


(Helgard de Barros) #14

Ok, that seems to be working fine. Will have to test on a few machines that are not 1920 x 1080 to make sure, but for now it seems fixed.


(Helgard de Barros) #15

Mmmm, seems like I have a new bug.

In my project settings, I have this as the default.

23

In my editor it seems to be working right, but if I do a build, the lowest quality setting is what comes up as the default.

I can’t see any way to force it to set the default to the best in the blocks.

The only option I have is to increase the quality, but that only increases it by one setting. This wasn’t happening before, so not sure why it is happening now.


(Leslie Young) #16

Could be that Unity forces it cause of existing quality and resolution data saved for the game. That Block is getting its data directly from Unity via QualitySettings.GetQualityLevel() - either you chose the lowest as a test for the last time or you ran the game and then made changes to what quality levels there are (in editor) and now the game reverts to the lowest by default (to not cause index errors) since that is the 1st in the list.

Try enabling that window that pops up before game start to see if you can select a quality level there and what it is at when the game starts.


(Helgard de Barros) #17

Leslie,

In my editor, I deleted all saves, started the game and checked that the default was the best quality. Then I did a build with the window checked, and this is how it starts.

26

This seems to only be happening since I changed the screen resolution to the drop down, but I can’t see how that could affect it.

Edit: In my build version, if I start a game, set the quality to Fantastic, play and save a game, when I start the game again, the quality level is back to Fastest.

This has also been since I upgraded to 2017.3, so I don’t know if that could be having an effect?


(Helgard de Barros) #18

@Alien, do you know if your drop down script could be causing this? I switched back to the old programming before the drop down script and then this doesn’t happen.


(Alien) #19

not that I’m aware of. its not really touching the quality settings at all.


(Leslie Young) #20

I deleted all saves
and this is how it starts

Will not help since the resolution and quality data is comming from wherever Unity saves that data and not from where plyGame saves it. Also, deleting save data via the Unity editor will nto help for a final built game since the editor and final builds save their data in different locations (different registry keys).

If I click the “apply” button, it reverts

The Apply button is using the plyBlox “Apply Resolution” which had nothing to do with the script you used. It expect you to have made plyBlox calls to update the “selected” resolution as shown in my settings screen video. So, since you did not make those call it will change to whatever last thing it knows about. Yes, you need to remove “apply resolution” since the sript seems to apply it on the spot when you choose a new resolution.

do you know if your drop down script could be causing this

No. that script (attached in this thread) does not mess around with the quality settings. Test the build on a different computer and you will probably see it start up with the defaults you set in Unity.

One thing to keep in mind is that plyGame will override whatever you select in that first dialogue if there is currently saved settings. plyGame does save what you select so that it force restore to those settings when the game starts. That is one reason to not have that dialogue (except for while you are testing stuff). So ye, testing on your current device will not really help since there is data saved related to this.

One thing you can try is to make it look like a different game. This way you start with no saves. Go to Edit > Project Settings > Player and change the Company and Product names. These are what is used when generating the save keys.

You will find the product name in the registry if you run regedit and search for that name. That is one way of inspecting what values are saved for the game and you could simply delete the registry entry to also get rid of the saved data. Just be sure to be looking at the correct entry since there would be one for the Unity editor version and one for the stand-alone version of the game.