Пример #1
0
    IEnumerator IOSScreenshot(string albumName, string fileName, Rect screenArea, Action <SaveStatus> Done)
    {
        yield return(new WaitForEndOfFrame());

#if UNITY_IOS
        Texture2D texture = new Texture2D((int)screenArea.width, (int)screenArea.height, TextureFormat.RGB24, false);
        texture.ReadPixels(screenArea, 0, 0);
        texture.Apply();

        byte[] bytes;
        bytes = texture.EncodeToPNG();

        if (OnScreenshotTaken != null)
        {
            OnScreenshotTaken(texture);
        }
        else
        {
            Destroy(texture);
        }

        string date = System.DateTime.Now.ToString("hh-mm-ss_dd-MM-yy");
        string screenshotFilename = fileName + "_" + date + ".png";
        string path = Application.persistentDataPath + "/" + screenshotFilename;
        Instance.StartCoroutine(Instance.IOSSave(bytes, fileName, path, ImageType.SCREENSHOT, SaveDone => {
            Done(SaveDone);
        }
                                                 ));
#endif
    }