【发布时间】:2020-09-09 19:13:29
【问题描述】:
我已经添加到我的游戏截图功能。在 Xcode 中构建它,但出现““FileNotFoundException:找不到文件”错误。为什么?
private IEnumerator TakeScreenshot()
{
string imageName = "LevelFinished" + current_level.ToString() + ".png";
ScreenCapture.CaptureScreenshot(Application.persistentDataPath + "/" + imageName);
yield return new WaitForSeconds(0.3f);
byte[] data = File.ReadAllBytes(Application.persistentDataPath + "/" + imageName);
Texture2D screenshotTexture = new Texture2D(Screen.width, Screen.height);
screenshotTexture.LoadImage(data);
Sprite screenshotSprite = Sprite.Create(screenshotTexture, new Rect(0, 0, Screen.width, Screen.height), new Vector2(0.5f, 0.5f));
UI_Image_final.transform.GetChild(0).GetComponent<Image>().sprite = screenshotSprite;
}
【问题讨论】: