[英]Capture screenshot synchronously
i am writing screen capture in my Unity3D
program. 我正在Unity3D
程序中编写屏幕截图。 with this method: 用这种方法:
Application.Capturescreenshot("fileName.txt");
it works well and it saved to the project root folder. 它运行良好,并保存到项目根文件夹。 now i want to move it to another path so i am checking if the file exist line after i am taking the capture, and it turns out that in the next line the capture did not saved yet. 现在我想将它移动到另一条路径,所以我正在检查文件是否在我捕获后存在行,结果发现在下一行中捕获还没有保存。 it probably happens asynchronous. 它可能发生异步。 i want this line to be executed synchronous. 我希望这条线同步执行。
what would be the easiest solution? 什么是最简单的解决方案?
If the CaptureScreenshot
API doesn't give you a way to either do it synchronously or execute a delegate when the file has been saved, then you have two options: 如果CaptureScreenshot
API没有为您提供同步执行或在保存文件时执行委托的方法,那么您有两个选择:
FileSystemWatcher
to watch the folder for changes. 使用FileSystemWatcher
查看文件夹以进行更改。 You can give the watcher a delegate that will be executed whenever a file is added to the folder, and you can use the delegate to move the file. 您可以为观察者提供一个代表,只要将文件添加到文件夹就会执行该委托,您可以使用委托来移动文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.