R
R
Roman2020-05-22 23:43:44
iOS
Roman, 2020-05-22 23:43:44

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

1 answer(s)
2
2CHEVSKII, 2020-05-23
@2chevskii

It is enough to read the docs a little more carefully.
5ec864511200a648589464.jpeg
Suggests what you are doing wrong?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question