Esempio n. 1
0
    // Token: 0x0600010F RID: 271 RVA: 0x00009688 File Offset: 0x00007A88
    private IEnumerator GrabScreenshot(string fileName, string albumName, string fileType, Rect screenArea)
    {
        yield return(new WaitForEndOfFrame());

        Texture2D texture = new Texture2D((int)screenArea.width, (int)screenArea.height, TextureFormat.RGB24, false);

        texture.ReadPixels(screenArea, 0, 0);
        texture.Apply();
        byte[] bytes;
        string fileExt;

        if (fileType == "png")
        {
            bytes   = texture.EncodeToPNG();
            fileExt = ".png";
        }
        else
        {
            bytes   = texture.EncodeToJPG();
            fileExt = ".jpg";
        }
        if (ScreenshotManager.OnScreenshotTaken != null)
        {
            ScreenshotManager.OnScreenshotTaken(texture);
        }
        else
        {
            UnityEngine.Object.Destroy(texture);
        }
        string date = DateTime.Now.ToString("hh-mm-ss_dd-MM-yy");
        string screenshotFilename = fileName + "_ADIL" + fileExt;
        string path = Application.persistentDataPath + "/" + screenshotFilename;

        if (Application.platform == RuntimePlatform.Android)
        {
            string path2 = Path.Combine(albumName, screenshotFilename);
            path = Path.Combine(Application.persistentDataPath, path2);
            string directoryName = Path.GetDirectoryName(path);
            Directory.CreateDirectory(directoryName);
        }
        ScreenshotManager.Instance.StartCoroutine(ScreenshotManager.Instance.Save(bytes, fileName, path, ScreenshotManager.ImageType.SCREENSHOT));
        yield break;
    }