Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Grimmy · Jan 24, 2011 at 10:46 AM · screentogglefullscreenfull

Fullscreen Toggle Issue

Hi all, fullscreen toggling should be a relativley simple thing to sort out, but ever since day one I've had a problem which I cant seem to solve.

The following function runs all the time (from the update) and waits for a key input, no problems there and infact the variable isFullScreen gets changed as required, however the screen doesnt go fullscreen until you press the buttons again..and of course at that point the var gets set back to false so effectiveley the code works but ONLY if you press the buttons twice each time you want to toggle. Any ideas?

function FullScreenToggle() { fullScreenToggleKeyPressed= Input.GetKeyDown(fullScreenToggleKey);

 if(fullScreenToggleKeyPressed&&Input.GetKey (KeyCode.LeftShift)&&Input.GetKey (KeyCode.LeftAlt))
 {
     if (isFullScreen==false)
         {
             //this is some kind of error need to try !Screen.fullScreen; ? To test neeed a separate build.
             Screen.fullScreen = Screen.fullScreen;
             isFullScreen=true;
             return;
         }
     if (isFullScreen)
         {
             Screen.fullScreen = !Screen.fullScreen;
             isFullScreen=false;
             return;
         }
 }

}

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yoyo · Jan 24, 2011 at 05:31 PM 0
Share

Replace the inner two ifs with "Screen.fullScreen = !Screen.fullScreen;"

avatar image Grimmy · Jan 26, 2011 at 02:00 PM 0
Share

I dont understand what you mean. Do you mean replace both of the complete IF statements with one line? If so, where does my isFullScreen:boolean; statement go?

avatar image Grimmy · Jan 26, 2011 at 02:00 PM 0
Share

Could you perhaps cut and paste an example using the above code? Cheers

avatar image Wise_Dreamer · Apr 22, 2015 at 11:47 AM 0
Share

On Windows, Press the 'windows key' (between CTRL and ALT), and the 'right arrow' at the same time. It pushes the window to the right which exits full screen with a keyboard shortcut.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Chris 24 · Jan 24, 2011 at 10:59 AM

Is this in the webplayer? If so, thats been designed so that the user needs to click on the screen to allow it to go into fullscreen mode.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Grimmy · Jan 24, 2011 at 11:02 AM 0
Share

It is in the webplayer but this happens when the player is already in focus.

avatar image Grimmy · Jan 24, 2011 at 11:03 AM 0
Share

..or do you mean that there is an additional click required..? If so why and how do I get around it?

avatar image
0

Answer by Gillissie · Apr 20, 2011 at 01:33 AM

Your problem is this line of code, which doesn't do anything:

Screen.fullScreen = Screen.fullScreen;

You don't really need to use a variable to keep track of isFullScreen. Simply read Screen.fullScreen to find out if it is currently full screen.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by MMortal · Aug 21, 2013 at 10:09 PM

Here is how I got it to work for me (c#):

 void Update(){
 if(Input.GetKeyUp(KeyCode.F))
    ToggleFullScreen();
 }
 
 void ToggleFullScreen(){
    if(Screen.fullScreen= !Screen.fullScreen){
       Screen.fullScreen = Screen.fullScreen;
       Screen.SetResolution(Screen.width, Screen.height, true, 60);
 }else{
    Screen.fullScreen = !Screen.fullScreen;
 }

Hope it helps somebody.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MMortal · Aug 21, 2013 at 09:43 PM 0
Share

PS> Standalone Windows Version

avatar image undefined666 · May 12, 2018 at 04:12 PM 0
Share

You said Screen.fullScreen = Screen.fullScreen; doesn't do anything but there is the same line in your example.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Toggle full screen double click issue 2 Answers

OSX Build cannot go fullscreen? 0 Answers

RenderTextures and FullScreen Quads 2 Answers

Is it possible to change between exclusive fullscreen and borderless fullscreen in-game? 2 Answers

Screen.fullScreen is always false (Windows Store) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges