Ejemplo n.º 1
0
    IEnumerator TakeHiResShot()
    {
        btBack.transform.localScale  = new Vector3(0, 0, 0);
        btPhoto.transform.localScale = new Vector3(0, 0, 0);

        yield return(new WaitForEndOfFrame());


#if UNITY_ANDROID
        screenCapture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
        screenCapture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, false);
        screenCapture.Apply();

        NativeGallery.SaveToGallery(screenCapture, "Yokai", "my img {0}.jpeg");
#endif

#if UNITY_IOS
        screenCapture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
        screenCapture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, false);
        screenCapture.Apply();

        byte[] screenshot = screenCapture.EncodeToPNG();

        _GetTexture(screenshot, screenshot.Length);
#endif

        btBack.transform.localScale  = new Vector3(1, 1, 1);
        btPhoto.transform.localScale = new Vector3(1, 1, 1);

        yield return(new WaitForSeconds(0.5f));

        DialogTwitter.SetActive(true);
    }
Ejemplo n.º 2
0
 public bool SaveScreenshot(Texture2D texture)
 {
     if (!HasWriteAccess)
     {
         return(true);
     }
     try
     {
         // TODO need better way to generate incremental / unique images filenames
         NativeGallery.SaveToGallery(texture, "Antura", "AnturaSpace" + (Time.time / 1000) + ".png");
         return(true);
     }
     catch (Exception ex)
     {
         Debug.LogError("Exception during gallery saving: " + ex.Message);
         return(false);
     }
 }
Ejemplo n.º 3
0
    private IEnumerator TakeSS()
    {
        yield return(new WaitForEndOfFrame());

        Texture2D ss = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);

        ss.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        ss.Apply();

        if (!b)
        {
            NativeGallery.SaveToGallery(ss, "GalleryTest", "overwrite.png");               // not overwritten on iOS
        }
        else
        {
            NativeGallery.SaveToGallery(ss, "GalleryTest", "my img {0}.jpeg");
        }

        b = !b;
    }
Ejemplo n.º 4
0
 public void SaveScreenshot(Texture2D texture)
 {
     // TODO need better way to generate incremental / unique images filenames
     NativeGallery.SaveToGallery(texture, "Antura", "AnturaSpace" + (Time.time / 1000) + ".png");
 }