Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Screen Resolution Option tutorial and click behavior

edited April 6 in Technical Q&A

Hello,

This AC tutorial was followed to create a screen resolution option in the Options menu:
https://adventurecreator.org/tutorials/adding-screen-resolution-option

I was wondering what the expected behavior when clicking the "ScreenResolution" cycle element should be. Is the resolution intended to change on each single click? The menu's cycle element updates the displayed resolution upon each click during "Play mode".

Though when building the game / running it, the cycle element needs to be clicked on twice (or more times) for it to actually change the resolution.
For instance, while testing on my laptop, the first click feels like it "selects" the menu element. Then a second click results in the resolution change.

Testing on another desktop computer, it changes the resolution after one, two, three, or four clicks.
It feels like it's cycling through a list of resolutions in the background, then finally changes when it lands on one that it displays.
For example, it takes 4 clicks to go from 640x480 to 720x400.
2 clicks from 720x400 to 800x480
4 from 800x480 to 800x600
4 from 800x600 to 832x624
2 from 832x624 to 1024x600
3 from 1024x600 to 1024x768
3 from 1024x768 to 1152x864
2 from 1152x864 to 1152x872
2 from 1152x872 to 1280x720
1 from 1280x720 to 1280x768
2 from 1280x768 to 1280x800
2 from 1280x800 to 1280x960
1 from 1280x960 to 1280x1024
1 from 1280x1024 to 1400x1050
2 from 1400x1050 to 1440x900
Then 2 from 1440x900 back to the first value 640x480

As this is a visual issue, here's a video. After experiencing this in my game, I made a brand new fresh "test" game, and re-created the Screen Resolution Option to see if it still did the same thing (which is does), as the video shows:

This test is using Adventure Creator as the Option menu's source. And it does the same thing with my actual game's menu created in Unity UI. Using AC 1.70.4 and Unity 2019.3.7f1.

It also has a sort of "flicker" each time it's clicked to select it, which I'm wondering about.

One other question while thinking about it:
The tutorial mentions to put SetupOptionsMenu.cs on an empty GameObject in the game's first scene. Does this mean that it only needs to be placed on the first scene of the game that appears when it opens (e.g. a title-screen menu, etc.). Or would it also need to be on every other scene of the game?
One thing I wondered about when testing the game (typically only individual scenes at a time), the GameObject should be on the scene being tested -- since it's the first scene in that case.

Anyone else gone through the tutorial and experienced this? Thank you very much for any assistance!

Comments

  • AC and Unity versions?

    The flicker is due to the recalculation of AC menus according to the updated resolution.

    It should change on each click, though I wouldn't expect any behaviour in the Editor.

    It's difficult to tell what's going on in the video without knowing at what point you're clicking, but the resolution is changed by calling the tutorial's Engine: Apply resolution Action. The tutorial has this run when the Cycle element is clicked, but you could opt to have a separate "Apply" button that calls this Action instead - or even when the Menu is closed via it's ActionList when turn off field.

    Just be aware that if you have an "Apply" button, you'll need to rely on a second Variable to store the "temporary" resolution before it gets applied. It's a bit complicated, which is why it's left out of the tutorial, but essentially you'd want the process to be:

    1. When the menu is turned on, the "true resolution" variable value is copied to the "temporary resolution" one
    2. The Cycle element controls the "temporary resolution" variable
    3. When you click "Apply" the "temporary resolution" is copied back to the "true resolution" and the Engine: Apply resolution does its thing based on the "true resolution" value.

    This way, backing out of the Menu without clicking Apply has no effect.

  • edited April 7

    Thank you!

    Using AC 1.70.4 and Unity 2019.3.7f1.
    Ideally, yes I would like to create an "Apply" button eventually (and thank you for the information), though I believe it'd be wise to try and find out what's up with the basic functionality first.

    Here's a video with the clicks highlighted:

    I double-checked the code in both .cs files again, and everything is the same as in the tutorial.

    There is one difference from the tutorial to newer versions of AC / Unity, in the part where the "Set resolution" ActionList asset is created.
    The tutorial reads:

    Click Add new Action once to create a new Action, and set the Action type to Engine: Apply resolution.

    Though in the ActionList, it's under the Action type "Custom" (not under "Engine")
    https://imgur.com/a/5YVmtel

    For some reason I don't feel this makes a difference -- though just mentioning.
    Just supplying as much detail as possible in hopes to narrow the cause of the issue down.

    Thank you again for any assistance!

  • edited April 7

    I believe it'd be wise to try and find out what's up with the basic functionality first.

    True. With the version numbers, I'll attempt a recreation and let you know my findings.

    Though in the ActionList, it's under the Action type "Custom" (not under "Engine")

    Thanks. You're correct that this won't affect the issue, but I've amended the tutorial.

  • The issue was that it was displaying only the resolution's width/height, and not the refresh rate. Depending on your monitor, there can be several resolutions with the same size, but a different refresh rate.

    I've updated the tutorial to account for this, but you'll only need to update the first script.

  • edited April 9

    Thank you for the help and information! It does the trick.

    By the way, I was also wondering if the steps listed above to add an "Apply" button can be achieved with ActionLists?

    The second variable that stores the "temporary resolution" sounds as if it can be another AC global variable. The general steps and idea makes sense, though the parts where the variable get copied from one to another is a bit unclear; And if that can be handled with an ActionLists, e.g.

    When the menu is turned on, the "true resolution" variable value is copied to the "temporary resolution" one

    The more I read into it, it seems that some extra code would be needed to achieve.

    Is my understanding correct in that the "true resolution" variable value is what actually gets applied; And the "temporary resolution" variable value just serves as a kind of temporary placeholder, before it's applied?

  • That's correct - though extra code shouldn't necessary. The Variable: Copy Action can be used to transfer a variable's value.

  • Thank you! It works to switch the resolution.

    Was wondering about one other thing:
    There is also a bit of audio from the scene that plays between each resolution switch after clicking "Apply". Using Unity UI for all menus, by the way.

    It also did the same thing with the "previous" regular cycle method (without the "Apply" button added).
    I understand it's likely due to the menu "turning off" while the resolution switches, and unpausing for a split second.
    Any advice on how to account for that though?

    Thank you once again for your support! It's appreciated!

  • Wanted to add that I unchecked "Unfreeze 'pause' menus" in the Inspector for the Actionlist that gets run when clicking the "Apply" button, and it appears to have done the trick!

  • Yes, that's the correct solution.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!