Skip to content

Instantly share code, notes, and snippets.

@j796160836
Created October 2, 2013 23:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j796160836/6802354 to your computer and use it in GitHub Desktop.
Save j796160836/6802354 to your computer and use it in GitHub Desktop.
MultiScreen Support in Unity (for iOS)
using UnityEngine;
using System.Collections;
public class MultiScreen : MonoBehaviour
{
Camera extCam;
Camera extCam2d;
void Start ()
{
GameObject extCamObj = GameObject.Find ("ExtCamera");
extCam = extCamObj.camera;
GameObject extCam2dObj = GameObject.Find ("ExtCamera2d");
extCam2d = extCam2dObj.camera;
// GUI is rendered with last camera.
// As we want it to end up in the main screen, make sure main camera is the last one drawn.
extCam.depth = camera.depth - 1;
extCam2d.depth = camera.depth - 1;
camera.SetTargetBuffers (Display.main.colorBuffer, Display.main.depthBuffer);
extCam.enabled = false;
extCam2d.enabled = false;
}
void Update ()
{
if (Display.displays.Length > 1 && !extCam.enabled) {
Debug.Log ("Ext Display: " + Display.displays [1].systemWidth + "x" + Display.displays [1].systemHeight);
Display.displays [1].SetRenderingResolution (Display.displays [1].systemWidth, Display.displays [1].systemHeight);
extCam.SetTargetBuffers (Display.displays [1].colorBuffer, Display.displays [1].depthBuffer);
extCam2d.SetTargetBuffers (Display.displays [1].colorBuffer, Display.displays [1].depthBuffer);
}
extCam.enabled = Display.displays.Length > 1;
extCam2d.enabled = Display.displays.Length > 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment