banner



Readpixels Was Called To Read Pixels From System Frame Buffer, While Not Inside Drawing Frame.

Search Unity

Unity ID

A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate in the Unity community.

ReadPixels was called to read pixels from system frame buffer, while not inside drawi

Discussion in 'Android' started by fesp, Apr 20, 2013.

  1. fesp

    fesp

    Joined:
    Apr 19, 2013
    Posts:
    3
    Please bear with me as I'm new to Unity. I'm using Vuforia and the Prime31 Etcetera plugin and am trying to email a screenshot of the application on an Android device. Vuforia works fine, sending an email works fine, but as soon as I try to create the screenshot LogCat shows me:

    ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame.

    This is the code I'm using:

    1. void SendAndroidEmail( ) {
    2. int width = Screen. width ;
    3. int height = Screen. height ;
    4.         Texture2D tex = new Texture2D(width, height, TextureFormat. RGB24, false ) ;
    5.         tex. ReadPixels ( new Rect( 0, 0, width, height), 0, 0 ) ;
    6. byte [ ] bytes = tex. EncodeToPNG ( ) ;
    7. var path = System.IO . Path . Combine ( Application. persistentDataPath, "tmp_" + System . DateTime . Now . ToString ( ) + ".png" ) ;
    8. System.IO . File . WriteAllBytes ( path, bytes ) ;
    9.         EtceteraAndroid. showEmailComposer ( "noone@nothing.com", "Message subject", "click <a href='http://somelink.com'>here</a> for a present", true, path ) ;
    I have tried experimenting with yield but to no avail as I'm not sure what I'm doing...

    Thanks!

    Last edited: Apr 20, 2013
  2. fesp

    fesp

    Joined:
    Apr 19, 2013
    Posts:
    3
    I was able to get the screenshot by moving the code above from 'Update' to 'LateUpdate'. But unfortunately then in the the screenshot I can only see the camera image with the marker (or target), but not the model rendered on top of that...

    Is there some other place I need to execute this code form to get both the model and the camera image?

  3. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,459
  4. fesp

    fesp

    Joined:
    Apr 19, 2013
    Posts:
    3
    Thank your very much! OnPostRender did the trick.

Readpixels Was Called To Read Pixels From System Frame Buffer, While Not Inside Drawing Frame.

Source: https://forum.unity.com/threads/readpixels-was-called-to-read-pixels-from-system-frame-buffer-while-not-inside-drawi.179111/

Posted by: cattplithenewark.blogspot.com

0 Response to "Readpixels Was Called To Read Pixels From System Frame Buffer, While Not Inside Drawing Frame."

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel