Beispiel #1
0
        private IEnumerator captureScreenshotCor(
                        CallBackTex2D callback,
                        string fileName,
                        string folderName,
                        bool isOverWrite)
        {
            string folderPath = this.getFolderPath(folderName);
            #if UNITY_IOS
                // iOSだとiCloudにバックアップを取りすぎるとリジェクトされる為,バックアップ属性指定フォルダのバックアップ属性を外す.
                Device.SetNoBackupFlag( folderName );
            #endif
            fileName += PICTURE_EXTENSION;
            string filePath = folderPath + fileName;

            yield return new WaitForEndOfFrame();
            // 撮影.
            Texture2D tex = new Texture2D(Screen.width, Screen.height, TextureFormat.ARGB32, false);
            tex.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, false);
            tex.Apply();

            // キャプチャ用の情報を作成.
            string captureID = this.getNowTimeString();
            CaptureInfo info = new CaptureInfo(filePath, captureID, tex.EncodeToPNG());
            this.captureList.Add(captureID, info);

            // コールバックでスプライトを先に渡す.
            callback(tex, filePath);

            // 別スレッドを作成しそっちで保存.
            Thread thread = new Thread(new ParameterizedThreadStart(this.saveCaptureImageThd));
            thread.Start(captureID);
            while (!this.captureList[captureID].IsFinished)
            {
                yield return new WaitForSeconds(0);
            }

            yield return new WaitForEndOfFrame();
        }
Beispiel #2
0
 // スクリーンショットを撮影し,コールバックでTexture2Dとファイルパスを返す.
 public void captureScreenshot(
                 MonoBehaviour mono,
                 CallBackTex2D callback,
                 string fileName,
                 string folderPath = "",
                 bool isOverWrite = true)
 {
     mono.StartCoroutine(captureScreenshotCor(callback, fileName, folderPath, isOverWrite));
 }