Tag: c

使用ScreenCapture.CaptureScreenshot捕获并保存屏幕截图

我一直试图截取屏幕截图,然后立即使用它来显示某种预览,有时它会起作用,有时却不起作用,我目前没有工作,我没有统一这台计算机所以我会尝试在运行中重新创建它(这里可能存在一些语法错误) public GameObject screenshotPreview; public void TakeScreenshot () { string imageName = “screenshot.png”; // Take the screenshot ScreenCapture.CaptureScreenshot (imageName); // Read the data from the file byte[] data = File.ReadAllBytes(Application.persistentDataPath + “/” + imageName); // Create the texture Texture2D screenshotTexture = new Texture2D(Screen.width, Screen.height); // Load the image screenshotTexture.LoadImage(data); // Create a sprite Sprite screenshotSprite […]