提供对显示器/屏幕的访问,以便进行渲染操作。
Unity supports multi-display rendering on:
Desktop platforms (Windows, macOS X, and Linux)
Android (OpenGL ES and Vulkan)
iOS
Some features in the Display class only work on some of the supported platforms. See the properties and methods for more information about platform compatibility.
使用 Display 类可在显示器本身上进行操作,使用 Camera.targetDisplay 可设置摄像机,以便分别渲染到各显示器。
另请参阅:Camera.targetDisplay、Canvas.targetDisplay。
using UnityEngine;
public class Example : MonoBehaviour { Camera extCam; Camera cam;
void Start() { // 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 = cam.depth - 1;
cam.SetTargetBuffers(Display.main.colorBuffer, Display.main.depthBuffer); extCam.enabled = false; }
void Update() { if (Display.displays.Length > 1 && !extCam.enabled) { Display.displays[1].SetRenderingResolution(256, 256); extCam.SetTargetBuffers(Display.displays[1].colorBuffer, Display.displays[1].depthBuffer); } extCam.enabled = Display.displays.Length > 1; } }
activeEditorGameViewTarget | Get the Editors active GameView display target. |
displays | The list of connected displays. |
main | 主显示器。 |
active | 获取该显示器的状态,如果该显示器处于活动状态,返回 true,否则返回 false。 |
colorBuffer | 颜色 RenderBuffer。 |
depthBuffer | 深度 RenderBuffer。 |
renderingHeight | 该显示器正在渲染时所采用的垂直分辨率。 |
renderingWidth | Horizontal resolution that the display is rendering at in the viewport. |
requiresBlitToBackbuffer | 当后缓冲区需要中间纹理进行渲染时为 true。 |
requiresSrgbBlitToBackbuffer | 当对后缓冲区进行 blit 需要手动进行颜色空间转换时为 true。 |
systemHeight | 垂直原生显示分辨率。 |
systemWidth | 水平原生显示分辨率。 |
Activate | Activates an external display. For example, a secondary monitor connected to the system. |
SetParams | Windows platforms only. Sets rendering size and position on screen. |
SetRenderingResolution | 设置该显示器的渲染分辨率。 |
RelativeMouseAt | 查询相对鼠标坐标。 |