Unity 截屏 实现 验证
- ScreenCapture.CaptureScreenshot(string fileName, ScreenCapture.StereoScreenCaptureMode mode)
- 需要在游戏运行的时候执行
using UnityEditor;
using UnityEngine;
public class ScreenCaptureMenu
{
[MenuItem("ShareBlog/ScreenCapture")]
public static void Capture()
{
//pc windows平台
ScreenCapture.CaptureScreenshot("D:/hello capture.png");//没有产生截图
ScreenCapture.CaptureScreenshot("D:/hello capture left.png", ScreenCapture.StereoScreenCaptureMode.LeftEye);//没有产生截图
ScreenCapture.CaptureScreenshot("D:/hello capture right.png", ScreenCapture.StereoScreenCaptureMode.RightEye);//没有产生截图
ScreenCapture.CaptureScreenshot("D:/hello capture both.png", ScreenCapture.StereoScreenCaptureMode.BothEyes);//产生截图
ScreenCapture.CaptureScreenshot("D:/hello capture both2", ScreenCapture.StereoScreenCaptureMode.BothEyes);//产生截图 但是没有后缀名
//android平台下会把文件名追加到Application.persistentDataPath之后
Debug.Log(Application.persistentDataPath);
#if UNITY_ANDROID
ScreenCapture.CaptureScreenshot("hello capture both.png", ScreenCapture.StereoScreenCaptureMode.BothEyes);//产生截图
#endif
}
}