Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Cannot fullscreen through code or player options

Discussion in 'General Graphics' started by itsrandxm, Jun 20, 2021.

  1. itsrandxm

    itsrandxm

    Joined:
    Nov 17, 2020
    Posts:
    4
    [It just started to work out of nowhere, I have no idea why]
    (This is a repost from Editor and General support because I didn't get any responses)

    In my game, I am trying to give the option to switch between fullscreen and windowed. Here is my current code.


    Code (CSharp):
    1.  
    2.         // If statement working.
    3.         if (optionValues[2] == "1")
    4.         {
    5.             Debug.Log("On");
    6.             optionToggles[0].isOn = true;
    7.             Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
    8.             Screen.fullScreen = true;
    9.         }
    10.         else
    11.         {
    12.             Debug.Log("Off");
    13.             optionToggles[0].isOn = false;
    14.             Screen.fullScreenMode = FullScreenMode.Windowed;
    15.             Screen.fullScreen = false;
    16.         }
    17.         Debug.Log(Screen.fullScreen);
    18.         // Output: false.
    19.         Debug.Log(Screen.fullScreenMode);
    20.         // Output: Windowed.
    21.  
    Both "On" and "Off" are logged and I am setting the FullScreenMode and Screen.fullScreen, however the only option that seems to change anything is what I do in the player options, I have tried everything I can and I have no idea what is wrong, it seems unity just isn't working properly. I even tried this solution https://forum.unity.com/threads/uni...-build-possible-solution.530863/#post-3515453. I am confused and I have no idea what to do so some help would be appreciated.
     
    Last edited: Jun 28, 2021