我有一个简单的屏幕保护程序,该程序在Unity上进行了多屏显示。它设置为在全屏模式下工作,但是有一半的时间在进入全屏模式之前会短暂打开一个窗口。它每隔一次发生一次,我无法确定问题出在哪里。
void Start()
{
InitDisplays();
}
void InitDisplays()
{
Camera cameraPrefab = Resources.Load<Camera>(displayCameraPrefab);
Canvas displayPrefab = Resources.Load<Canvas>(displayCanvasPrefab);
for (int i = 0; i < Display.displays.Length; i++)
{
InitDisplay(i, cameraPrefab, displayPrefab);
}
}
void InitDisplay(int displayIndex, Camera cameraPrefab, Canvas displayPrefab)
{
Display d = Display.displays[displayIndex];
d.Activate();
Camera displayCamera = Instantiate(cameraPrefab, cameraContainer, false);
Canvas displayCanvas = Instantiate(displayPrefab);
displayCamera.name = string.Format("DisplayCamera{0}", displayIndex);
displayCamera.targetDisplay = displayIndex;
displayCanvas.name = string.Format("DisplayCanvas{0}", displayIndex);
displayCanvas.targetDisplay = displayIndex;
DataManager.instance.AddDataToCanvas(displayCanvas);
}