我正在创建一个应用程序,希望能够存储屏幕截图,并在之后显示它。我的代码运行良好,截图也被存储并似乎没有问题地被程序接收到。然而,截图没有显示出来,这让人相当沮丧。以下是我的代码:
void OnGUI(){
if (GUI.Button (new Rect(940,y+25, Screen.width/30, Screen.height/14), Tex7)){
Debug.Log ("Selfie-maker");
folderPath = Application.persistentDataPath + "/screenshot.png";
Application.CaptureScreenshot(folderPath);
Debug.Log ("Screenshot number " + screenshotCount +" taken!");
screenshotCount ++;
}
if(GUI.Button (new Rect(940,y+65, Screen.width/30, Screen.height/14), Tex)){
Debug.Log ("Anders");
fileName = Path.Combine(Application.persistentDataPath, "screenshot.png");
bytes = File.ReadAllBytes(fileName);
screenshot = new Texture2D(0,0,TextureFormat.ATF_RGB_DXT1, false);
screenshot.LoadImage(bytes);
}
}
我希望我提供的信息已经足够。如果不够,请随时提出问题。
screenshot
对象来自哪里?它是Unity的GameObject
吗? - Ludovic Feltz