using
1using System.Collections.Generic; 2using UnityEngine; 3using UnityEngine.UI; 4using System.IO; 5using System; 6public class ScreenShotScript : MonoBehaviour { 7// スクリーンショットボタン 8[SerializeField] 9private GameObject screenShotButton; 10// ログパネル 11[SerializeField] 12private GameObject logPanel; 13// 解像度パネル 14[SerializeField] 15private GameObject superSizePanel; 16// 解像度レベルスライダー 17[SerializeField] 18private Slider superSizeSlider; 19// 解像度レベルテキスト 20[SerializeField] 21private Text superSizeText; 22// スクリーンショットを撮ってからの待ち時間 23[SerializeField] 24private float waitTime = 5f; 25// データの保存先ファイルパス 26private string saveFilePath = "/Projects/ScreenShot"; 27// 保存ファイル名 28private string saveFileName = "/screenshot.PNG"; 29void Start() { 30// UIの初期設定 31screenShotButton.SetActive (true); 32logPanel.SetActive (false); 33superSizePanel.SetActive (true); 34// 指定したフォルダがない時はAssetsフォルダに保存 35if (!Directory.Exists(Application.dataPath + saveFilePath)) { 36saveFilePath = ""; 37} 38} 39// スクリーンショットボタンを押す 40public void OnScreenShot() { 41StartCoroutine(OperationUI ()); 42} 43// スクリーンショット処理 44IEnumerator OperationUI() { 45// スクリーンショットを撮る前にUIを全部非表示 46screenShotButton.SetActive (false); 47logPanel.SetActive (false); 48superSizePanel.SetActive (false); 49// スクリーンショットを撮る 50ScreenCapture.CaptureScreenshot(Application.dataPath + saveFilePath + saveFileName, (int)superSizeSlider.value); 51// 待ち時間を入れないとlogPanelが表示されるので一定時間待つ 52yield return new WaitForSeconds (0.1f); 53logPanel.transform.GetChild (0).GetComponent<Text> ().text = "スクリーンショットを撮りました!\n" + Application.dataPath + saveFilePath + saveFileName + " に保存されました。"; 54// スクリーンショットを撮った旨を表示 55logPanel.SetActive (true); 56yield return new WaitForSeconds (waitTime); 57// UIを元に戻す 58screenShotButton.SetActive (true); 59superSizePanel.SetActive (true); 60logPanel.SetActive (false); 61} 62// 画面サイズをテキストに表示 63public void ChangeSuperSizeText(Single value) { 64superSizeText.text = value.ToString(); 65} 66} 67 68コード
Unityを用いて
アンドロイドでカメラ映像を映し、スクショを取るというものを作成しました。
pcでは正常に動くのですが、andoroidで行いますと保存された画像がギャラリーに出てきません。
どのように改善すればよろしいでしょうか?
言葉足らずですみません。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/04 08:09