- Home /
Full Screen Mode
how do you switch out of full screen and to full screen fast? Like keyboard shortcut?
Next time go a little bit more in detail... and yes, a question can be longer than a single line ( much longer ).
http://answers.unity3d.com/faq
Answer by Bunny83 · Feb 22, 2011 at 02:01 AM
What you want is something like:
Edit
Since you didn't tell us what language you want to use, here's the Javascript version of the full script:
function Update()
{
if (Input.GetKeyDown(KeyCode.F))
Screen.fullScreen = !Screen.fullScreen;
}
And here's the C# version (in c# the file must have the same name as the class: "ToggleFullscreen"):
using UnityEngine; using System.Collections;
public class ToggleFullscreen : MonoBehaviour { void Update() { if (Input.GetKeyDown(KeyCode.F)) Screen.fullScreen = !Screen.fullScreen; } }
Scripts have to be attached to a GameObject in your game. For this script it doesn't matter on which object. Just drag it from your project view onto the gameobject you like (eg. MainCamera).
okay, but where do I put it in? where's the folder with the text file?
What do you mean? Don't you know how to create a script file and how to use it on a GameObject? I will edit my answer to show you how a full script would look like.
Bunny83, I didn't understand how to do this: create a script file and how to use it on a GameObject?
Sorry, I posted this comment as an answer.
Answer by GLeBaTi · Aug 13, 2015 at 01:43 PM
public class FullScreen : MonoBehaviour {
private int defWidth;
private int defHeight;
public void Awake()
{
defWidth = Screen.width;
defHeight = Screen.height;
if(!Application.isWebPlayer)
{
Destroy(this);
}
}
public void ChangeFullScreen()
{
if (!Screen.fullScreen)
{
Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
}
else
{
Screen.SetResolution(defWidth, defHeight, false);
}
}
}
This is the best answer because Screen.fullScreen = !Screen.fullScreen; doesn't restore windowed mode
Answer by ren · Feb 21, 2011 at 09:50 PM
Joshua, thanks for that solution, but I meant you can pretty much switch to fullscreen by right clicking then clicking full screen.
Don't use answers as comments!! Use comments! http://answers.unity3d.com/faq
No, this was useful comment. I searched for question «How switch to full screen in Unity3D?» and operatively found answer by request «unity3d full screen» in Google on second position in search already. Very thanks for this comment!
P.S.: but yes, maybe that little bit uncomfortably, but maybe that imperfection of system answers too? Don't know. And somebody know there are keyboard shorcuts for toggle player to full screen? Re$$anonymous$$d: that ask in first question.
Answer by ren · Apr 20, 2011 at 05:16 PM
Bunny83, I didn't understand how to do this: create a script file and how to use it on a GameObject?
Answer by Joshua · Feb 21, 2011 at 09:47 PM
Well, by default the button to go out of fullscreen is esc. And what do you mean, make unity fullscreen, make your scene fullscreen, make 'an' unitygame fullscreen?
Well, esc works only in the webplayer "automatically", but only for security reasons. You will also unlock the mouse if it was locked.
Your answer
![](https://koobas.hobune.stream/wayback/20220613105554im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
There is nothing in the GAME mode and nothing shows when the game is installed. 2 Answers
Playing movie without plane 1 Answer
Full screen coordinates 1 Answer
Make my HUD full screen 2 Answers
How do I make my game fullscreen 3 Answers