Version: Unity 6.6 Alpha (6000.6)
Language : English
Windowing APIs overview
Embedded Linux

Create a multi-window application

Use the Windowing APIs to create multiple windows for your application at runtime. Each window can display content from a cameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary
, allowing you to render different content across multiple windows.

Unity creates the main window by default. The following steps demonstrate how you can use the Windowing APIs to add a secondary window to your application at runtime. You can use the same approach to create up to eight windows in total, including the main window.

Prerequisites

1. Configure the scene and camera components

Set up your Unity project with the required build profilesA set of customizable configuration settings to use when creating a build for your target platform. More info
See in Glossary
for the target platform and configure cameras for each window as follows:

  1. In your Unity project, create a build profile for the target platform.

  2. Create a sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
    See in Glossary
    for the build profile.

  3. Add a second camera to the scene (menu: GameObject > Camera).

    Note: Unity includes a main camera by default. For a two window application, you need two cameras.

  4. Select the second camera.

  5. In the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
    See in Glossary
    window, open the Output section, and set the Target Display to Display 2.

This configuration ensures that the second camera renders to Display 2 which corresponds to the second window you want to create at runtime.

Display UI only on the second window (Optional)

Follow these steps if you want to display UI elements on the second window:

  1. Create a canvas (menu: GameObject > UI (Canvas) > Canvas).
  2. Select the canvas.
  3. In the Inspector window, set the Render Mode to Screen Space - Overlay and Target Display to Display 2.

2. Create the second window using C# script

Use a script that creates the second window to display content from the camera you configured in Step 1.

  1. In the Project window, create a C# script (context menu: Create > MonoBehaviour Script).

  2. Replace the default script with the following:

    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Windowing;
    
    public class CreateWindowExample : MonoBehaviour
    {
        List<DisplayInfo> displayInfos = new List<DisplayInfo>();
        
        void Start()
        {
            DisplayInfo.GetLayout(displayInfos);
            
            var settings = new GameWindowCreationSettings(
                title: "Second Window",
                width: 600, 
                height: 400,
                position: new Vector2Int(0, 0),
                cameraDisplayIndex: 1,         // Target Display index of the camera
                displayInfo: displayInfos[0]  // Physical display that will contain the window
            );
            
            var op = GameWindowManager.Create(settings);
            
            op.completed += (AsyncOperation o) => {
                // Triggers when the window creation is complete
                Debug.Log($"Window Created: {op.window.GetTitle()}");
            };
        }
    }
    
  3. Configure the following key parameters as required.

    • displayInfo: Specifies which physical display contains the window. Retrieve the display information using DisplayInfo.GetLayout (recommended) or Screen.GetDisplayLayout. In the example, displayInfos[0] uses the first physical display.
    • cameraDisplayIndex: Specifies which camera’s content to display based on the camera’s Target Display setting from Step 1. For example, use 0 for Display 1, and 1 for Display 2.
  4. Attach the script to a GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
    See in Glossary
    in the scene.

Notes:

3. Build and run the application on target hardware

  1. Build the Player for the Embedded Linux or QNX build profile.
  2. Deploy and run the Player on the target hardware to verify whether the additional window appears on the correct display.

Limitations

Consider the following limitations when designing a multi-window application:

  • Unity supports a maximum of eight target displays, which limits the number of windows you can create.
  • In fullscreen mode, secondary windows use the resolution of the physical display they appear on. Changing the window resolution through the GameWindow.SetResolution method isn’t supported.
  • GetLogicalDpi is currently not supported on Embedded Linux or QNX platforms. The method returns a default value of 0 on these platforms.

Additional resources

Windowing APIs overview
Embedded Linux