Switch between windowed and full-screen mode

Page update date :
Page creation date :

Verification environment

  • Windows 11
Unity Editor
  • 2021.3.3f1
Input System Packages
  • 1.3.0

Prerequisites for this tip

The following settings are pre-configured as a prerequisite for the explanation of these tips.

How to switch between windowed and full-screen mode

It's Screen.fullScreen very easy because you just need to specify or false for a property true in your program.

Of course, it works for games for PC. WebGL games can also be displayed in full screen if your web browser supports full-screen mode.

On the other hand, for mobile devices such as smartphones, it is basically full screen, so this switching is almost always ineffective.

Steps to switch between windowed and full-screen mode

If you are used to it, as long as you Screen.fullScreen know the properties, that's it, but here we will make a sample and try it out.

First, arrange the UI so that you can click a button to switch modes, as shown in the figure.

Place the script for the button handling. ButtonEvent For now, leave it as .

The script looks like this:

using UnityEngine;

public class ButtonEvent : MonoBehaviour
  public void OnClickFullScreenMode()
    // フルスクリーンモードに切り替えます
    Screen.fullScreen = true;

  public void OnClickWindowMode()
    // ウィンドウモードに切り替えます
    Screen.fullScreen = false;

I'm creating a method for each button. As Screen.fullScreen already described, you can set to full-screen mode, andfalse you can set to true windowed mode.

The script must be attached to the EventSystem.

Make sure to register a method in the click event of each of the two buttons.

This process cannot be seen in a debug run of the Unity Editor. Try outputting it once for PC or WebGL from the build settings, and then run it.

Click the button to see if it switches modes.

It also works fine with WebGL. By the way, the WebGL sample has a full-screen button in the lower right corner, so you can click it to go into full-screen mode. (Japanese is not displayed in the image because Japanese font is not included)