4
我正在創建一個應用程序,我希望能夠存儲屏幕截圖,然後再顯示它。我的代碼運行良好,屏幕截圖存儲並看似也沒有問題的程序收到。但是,它沒有顯示屏幕截圖,這非常令人沮喪。這是我的代碼:截圖截圖和顯示
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);
}
}
我希望我提供的信息就足夠了。如果不是,請不要猶豫,問。
這可能是一個好主意,還張貼此對http://answers.unity3d.com/ – sydan 2014-10-30 15:18:23
哪裏你'screenshot'對象從何而來?它是一個Unity GameObject嗎? – 2014-10-31 13:24:00