如何使用 Unity3D 为 iPad Pro 创建多屏体验?
How can I create a multi-screen experience for an iPad Pro using Unity3D?
多年来,Apple 一直提供在连接的屏幕上显示与驱动它的 iOS 设备上的内容不同的功能。
有没有办法在 Unity 内置的应用程序中使用此功能?即,iPad 会显示一个摄像头视图,而通过 USB-C 连接器通过 HDMI 连接的电视会显示不同的摄像头视图吗?
Apple 文档文章是 here, and a nice walkthrough is here。
This article 解释了如何在 Unity 和 Swift 之间发送消息,但它的范围似乎相当有限。
不幸的是,iOS 不支持正常的 Unity MultiDisplay 工作流程,因此解决方案有点棘手:
using UnityEngine;
using System.Collections;
public class MultiScreen : MonoBehaviour
{
// set the two cameras via the inspector
public Camera primaryCam;
public Camera secondaryCam;
void Start()
{
// render the primary camera to the main display
primaryCam.SetTargetBuffers(Display.main.colorBuffer, Display.main.depthBuffer);
secondaryCam.depth = primaryCam.depth - 1;
secondaryCam.enabled = false;
}
void Update()
{
// only render the second display if it is attached
if (Display.displays.Length > 1 && !secondaryCam.enabled)
{
// set the second display's resolution
Display.displays[1].SetRenderingResolution(Display.displays[1].systemWidth, Display.displays[1].systemHeight);
// render the secondary camera to the second display
secondaryCam.SetTargetBuffers(Display.displays[1].colorBuffer, Display.displays[1].depthBuffer);
}
// activate the second camera and render pipeline if a second display is connected
secondaryCam.enabled = Display.displays.Length > 1;
}
}
此外,我必须确保 Auto Graphics API
在 Project Settings > Player > Other Settings > Rendering
中被停用,并且 Metal
已从以下列表中删除。设置 Company Name
、Product Name
和 Bundle Identifier
可能也有帮助。
多年来,Apple 一直提供在连接的屏幕上显示与驱动它的 iOS 设备上的内容不同的功能。
有没有办法在 Unity 内置的应用程序中使用此功能?即,iPad 会显示一个摄像头视图,而通过 USB-C 连接器通过 HDMI 连接的电视会显示不同的摄像头视图吗?
Apple 文档文章是 here, and a nice walkthrough is here。
This article 解释了如何在 Unity 和 Swift 之间发送消息,但它的范围似乎相当有限。
不幸的是,iOS 不支持正常的 Unity MultiDisplay 工作流程,因此解决方案有点棘手:
using UnityEngine;
using System.Collections;
public class MultiScreen : MonoBehaviour
{
// set the two cameras via the inspector
public Camera primaryCam;
public Camera secondaryCam;
void Start()
{
// render the primary camera to the main display
primaryCam.SetTargetBuffers(Display.main.colorBuffer, Display.main.depthBuffer);
secondaryCam.depth = primaryCam.depth - 1;
secondaryCam.enabled = false;
}
void Update()
{
// only render the second display if it is attached
if (Display.displays.Length > 1 && !secondaryCam.enabled)
{
// set the second display's resolution
Display.displays[1].SetRenderingResolution(Display.displays[1].systemWidth, Display.displays[1].systemHeight);
// render the secondary camera to the second display
secondaryCam.SetTargetBuffers(Display.displays[1].colorBuffer, Display.displays[1].depthBuffer);
}
// activate the second camera and render pipeline if a second display is connected
secondaryCam.enabled = Display.displays.Length > 1;
}
}
此外,我必须确保 Auto Graphics API
在 Project Settings > Player > Other Settings > Rendering
中被停用,并且 Metal
已从以下列表中删除。设置 Company Name
、Product Name
和 Bundle Identifier
可能也有帮助。