Forum rules - please read before posting.

How to toggle windowed/full screen via Menu?

edited July 2024 in Technical Q&A

Hello again!
I followed the tutorial:
https://www.adventurecreator.org/tutorials/adding-screen-resolution-option
But I only want a 1920x1080(windowed)/1920x1080(fullscreen) toggle button. Maybe it's a similar logic, but how am I supposed to do?
Thank you!

Comments

  • You likely wouldn't need the SetupOptionsMenu script - just change the variable to a Boolean ("IsFullScreen"), and have the custom Action update the resolution this way:

    override public float Run ()
    {
        bool isFullScreen = GlobalVariables.GetIntegerValue (0); // Replace '0' with your own variable's ID number
        if (isFullScreen)
        {
            Screen.SetResolution (1920, 1080, isFullScreen);
            KickStarter.playerMenus.RecalculateAll ();
        }
        return 0f;
    }
    

    You can then link the Boolean variable to a Toggle element in your Options menu.

  • Thank you so much! I also used chatGPT to help me based on your script, problem solved!

  • hi,

    maybe someone has come across this topic

    is there a way to implement toggle only to switch between fullscreen and windowed mode?

    the script above gives an error, I can't quite figure out how to use it

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.