I was wondering how to script(prefably in javascript) a full screen button, so if you click f the game will become full screen. If you could tell me how do that, that would be great!
http://unity3d.com/support/documentation/ScriptReference/GUI.Button.html
http://unity3d.com/support/documentation/ScriptReference/Screen-fullScreen.html
http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html
I have also noticed a problem with trying to go full screen. I have the following code in the Update function:
` if(Input.GetButtonUp("Fullscreen Toggle")) { Screen.fullScreen = !Screen.fullScreen; Debug,Log("Fullscreen: " + Screen.fullScreen); } `
I get the Debug.Log message with every press of the key, but the message always returns false.
It’s a little late but for anyone else that is interested the reason it returns false is that you set it false with:
Screen.fullScreen = !Screen.fullScreen;
To enter fullscreen:
Screen.fullScreen = true;
Solution Example:
if (Input.GetButtonUp("Fullscreen Toggle")) {
if (!Screen.fullScreen) {
Screen.fullScreen = true;
} else {
Screen.fullScreen = !Screen.fullScreen;
}
Debug.Log("Fullscreen: " + Screen.fullScreen);
}
Or just do that:
using UnityEngine;
using System.Collections;
public class screenFull : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
if (GUILayout.Button("FullScreen"))
Screen.fullScreen = !Screen.fullScreen;
}
}