Answer the question
In order to leave comments, you need to log in
Why doesn't System.IO work?
Hello!
I added a screenshot to the game, I decided to test it. Build through XCode, error in logs - "FileNotFoundException: Could not find file". The eternal question: why?
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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question