Search Unity

Question Black screenshot on galaxy s7

Discussion in 'Scripting' started by artmatv, Feb 19, 2021.

  1. artmatv

    artmatv

    Joined:
    Apr 20, 2018
    Posts:
    2
    I'm using the AR Foundation and I have a bug that the screenshot is black only on galaxy s7, other phones are just fine. Black screen without UI or other stuff, so the problem is not inside the AR Foundation because I can't even see the UI. No errors found in the debugger
    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3.  
    4. public class TakeScreenshotService : MonoBehaviour
    5. {
    6.  
    7.     public void ScreenShot(string path)
    8.     {
    9.         StartCoroutine(TakeScreenshot(path));
    10.     }
    11.  
    12.     public IEnumerator TakeScreenshot(string path)
    13.     {
    14.         Debug.Log("TakeScreenshot start of method");
    15.         string[] pathStrings = path.Split(',');
    16.         if (pathStrings.Length != 2)
    17.         {
    18.             Debug.Log("Need to supply a comma separated list of folder and file name");
    19.             yield break;
    20.         }
    21.  
    22.         Debug.Log("Take screenshot");
    23.         var texture = ScreenCapture.CaptureScreenshotAsTexture();
    24.         texture.Apply();
    25.         Debug.Log("ScreenCapture done");
    26.  
    27.         NativeGallery.SaveImageToGallery(texture, pathStrings[0], pathStrings[1]);
    28.         Debug.Log("Saved to gallery");
    29.     }
    30. }