Created
October 2, 2013 23:54
-
-
Save j796160836/6802354 to your computer and use it in GitHub Desktop.
MultiScreen Support in Unity (for iOS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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