> For the complete documentation index, see [llms.txt](https://lfdocs.lookingglassfactory.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lfdocs.lookingglassfactory.com/software/index/prefabs/dual-monitor-application.md).

# Dual Monitor Application

Dual monitor functionality is intended to enable the creation of dual monitor applications. Using this pipeline, you can have a windowed application on your 2D monitor while rendering a holographic scene on your Looking Glass device. This is achieved by creating an inter-process communicator (IPC) between two Unity applications.

## **Reviewing the Example Scene**

To fully load the example scene:

1. Open `LookingGlass\Examples\7 - Dual Monitor Application`
2. Select the `DMA Builder` GameObject from the scene hierarchy
3. In the `Dual Monitor Application Manager` script, select the `Setup\\Open Scenes` button

The `Setup\\Open Scenes` button loads in the `_extendedUI` scene of the same name. This scene drives the UI on the 2D window. If a scene doesn't exist by this name, this button will create it.

The additional example scene that gets incorporated includes:

It's own `DMA Builder` game object, with the `Dual Monitor Application Manager` script field for `Display` set to `Window 2D`. This is required so that the scenes can identify which displays they drive.

A canvas to manage the UI. Any Unity content is allowable here.

An IPC (inter-process communicator) that sends events between the two scenes.

## **Creating your Own Scene**

Follow these steps.

1. Create a New Scene
2. Remove the default Unity camera and add a `Hologram Camera` to the scene, found in `Assets/LookingGlass/Prefabs/`
3. Add the `Dual Monitor Application` prefab to your scene
4. Select the `DMA Builder` from the scene hierarchy, and click `Setup/Open Scene` - you'll need to save your scene first
5. Add a `DMA Builder` to the second scene
6. Set the second scene's `Dual Monitor Application`'s `Display` to `Window 2D`
7. Add a `DMA IPC` object to each scene (if cross-application communication is required
8. Set the `DMA IPC`'s `Dual Monitor Application Base IPC` to `Looking Glass` for the Looking Glass scene, and `Window 2D` for the 2D scene
9. Set the `Inter Process Communicator`'s `Role` to `Receiver` for the Looking Glass scene and `Sender` for the 2D scene
10. Change the `Inter Process Communicator`'s `Signing Char` to something new that matches in both scenes (recommended)

If the app requires UI elements on the 2D, this can be done using conventional Unity UI elements. There is a prefab provided for you for convenience, `DMA Canvas`, though you will need to additionally add an Event System to your scene for Unity UI events.

## **Building a Release**

In order to support all Looking Glass Pro functionality, you must build your applications in an unconventional way. Unity's built-in build pipeline will not work. To build the proper way:

Open File > Build Settings... and add both your scenes and click **Add Open Scenes** to add both scenes to the "Scenes in Build" field

Close the Build Settings window

Select any `DMA Builder` game object

Click the **Build (Dual Monitor Application)** button in the `Dual Monitor Application Manager` script in the inspector

Select **an empty folder** to bundle your application into

## **Scripting IPC Functionality**

In order to script your own functionality, follow the following steps:

1. In your script, add a reference to the `InterProcessCommunicator` in your scene.
2. To send data (typically from the 2D UI to the Looking Glass display) call `InterProcessCommunicator.SendData` with a string as the parameter. This will be sent to the receiver. You can call this function either from a script or from UI events.
3. In the receiving scene (typically the Looking Glass scene), in a script, create a reference to the `InterProcessCommunicator` in that scene.
4. Create a function named `ReceiveMessage(string message)`.
5. This function will now be called when a message is received. Write some logic within this function to handle the various messages the scene will be receiving.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lfdocs.lookingglassfactory.com/software/index/prefabs/dual-monitor-application.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
