【发布时间】:2017-07-05 14:56:42
【问题描述】:
我需要在 Unity 中制作屏幕截图。我用了下一个方法:
public void Capture(){
StartCoroutine(CaptureScreenshot());
}
private IEnumerator CaptureScreenshot(){
GameObject canvas = GameObject.Find("Canvas");
canvas.SetActive(false); // hide all buttons
yield return new WaitForEndOfFrame();
string timestamp = DateTime.Now.ToString("dd_MMMM_hh_mm_ss_tt");
Application.CaptureScreenshot("screenshot" + timestamp + ".png");
Debug.Log("Screenshot was captured.");
yield return new WaitForEndOfFrame();
canvas.SetActive(true); // restore all buttons
yield return null;
}
当我调用Capture() 时,画布会隐藏,但既不截屏也不记录文本。
这段代码有什么问题?感谢您的回复。
【问题讨论】:
-
协程是在画布上的游戏对象上运行的吗?
-
@ScottChamberlain 是的
-
禁用画布会使每个孩子都处于非活动状态......