Unityで作成したアプリにスクリーンショットの機能を装着したのですが
ボタンを押してから実際にスクリーンショット画像(png)になるまでがかなり遅いです。
シュミレーター実験でAssets/imagesフォルダにできるように設定してボタンを押してから
出来るまでの時間を計ると3分~10分くらいかかります。
設計上のミスがどこかにあるのでしょうか?速くする裏技みたいなものはあるのでしょうか?
環境)
PC: mac
Unity2018.2
言語:C#
空のGameObjectを作成して下記スクリプトをアタッチして
べつのUIのButtonのOnClick属性にPushScreenShot()を付けました。
画像はできることはできるのですが時間がかかり過ぎて現実的ではありません。
ScreenShotScript.cs
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScreenShotScript : MonoBehaviour { //ファイル名の指定 [SerializeField] private string _imageTitle = "imageA"; // Use this for initialization void Start () { } // Update is called once per frame void Update () { } public void PushScreenShot(){ StartCoroutine(imageShooting(_imageTitle)); } public IEnumerator imageShooting(string title){ string name = title + ".png"; yield return new WaitForSeconds(2.0f); ScreenCapture.CaptureScreenshot("Assets/images/" + name); Debug.Log("保存しました"); } }
new ScreenShotScript.cs
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScreenShotScript : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } public void PushScreenShot(){ ScreenCapture.CaptureScreenshot(Application.persistentDataPath + "/imageA.png"); Debug.Log("保存しました"); }
回答1件
あなたの回答
tips
プレビュー