• Register
0 votes

Problem :

I am trying to create the test app using unity but facing following issue:

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

6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Uou should wait until the end of the current frame encounters before taking the screenshot or before calling the function Texture2D.ReadPixels . This should be done with the WaitForEndOfFrame class. Please note  how I cached it to avoid the creation of new Object every time the function TakeSnapshot  is called.


WaitForEndOfFrame frameEnd = new WaitForEndOfFrame();

public IEnumerator TakeSnapshot(int width, int height)
yield return frameEnd;
Texture2D texture = new Texture2D(800, 800, TextureFormat.RGB24, true);
texture.ReadPixels(new Rect(0, 0, 800, 800), 0, 0);
sendTexture(texture, messageToSend);
This should fix your issue.
9 7 4
38,600 points

Related questions

0 votes
2 answers 542 views
Problem : I am new to Unity5. I am facing following error while trying to do setDestination. "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3) CompleteProject.EnemyMovement:Update() (at Assets/ ... ; } } } } May I know what is wrong with the above code? Does anyone have any solution on my issue?
asked Nov 27, 2019 alecxe 7.5k points
0 votes
1 answer 242 views
Problem : I am very new to C#. I have written the below C# code. void UpdateAxis () { float myxP = Input.GetAxis ("Horizontal")*Time.deltaTime * 20; transform.Translate (Vector3(myxP,0,0));//error is here transform.position.x = Mathf.Clamp (transform. ... the above code. error : Expression denotes a type', where avariable', value' ormethod group' was expected` Kindly suggest the solution if any.
asked Dec 3, 2019 alecxe 7.5k points
1 vote
2 answers 82 views
Problem: I am beginner to C# with Unity engine. I have already started learning C# with Unity engine. I have tried to write the very basic script as shown below for your reference: using UnityEngine; using System.Collections; public class scriptMyBall : MonoBehaviour { / ... but unable to fix the Unity Engine related error. I need Unity Engine’s expert who can guide me in fixing above error.
asked May 23, 2020 Martin K 6.6k points
1 vote
1 answer 213 views
Problem : Looking for the solution on bellow problem setting the parent of a transform which resides in a prefab is disabled to prevent data corruption
asked Nov 8, 2019 peterlaw 6.9k points
0 votes
1 answer 139 views
Cannot create controller in thread that did not call Looper.prepare () What does the following exception mean? How can I fix it? Here is the code: Toast toast = Toast.makeText (mContext, "Something", Toast.LENGTH_SHORT); This is the exception: Java.lang.RuntimeException: Cannot ... :121)      on Android.widget.Toast. <init> (Toast.Java:68)      on Android.widget.Toast.makeText (Toast.Java:231)
asked Aug 17, 2020 game 4.6k points
1 vote
3 answers 1.5K views
Problem : I am very new to unity. Recently I had updated my unity from the earlier unity5 to the current 2018.2.2f1. And after that update my Unity scripts are not at all loading. I had also tried to play my Scene but my scripts are not at all loading and I am ... time on fixing above error but still unable to fix it so looking for the expert help who can help me in fixing my issue in less time.
asked Apr 10, 2020 morrisBson 3.2k points
0 votes
1 answer 248 views
Problem : I want to send mails using my web application. But my below code is showing me the below error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send ... false; mysmtp.Timeout = 600000; } // Passing values to smtp object mysmtp.Send(myfromAddress, mytoAddress, mysubject, mybody); } } }
asked Dec 9, 2019 alecxe 7.5k points
0 votes
1 answer 31 views
Problem: Hi! I a working with a Desktop Application in C#. I am trying to run the following program: using System; using System.Windows.Forms; namespace multiple_conditions { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void okButton_Click( ... : 'Input string was not in a correct format.' I do not know what the problem is. Can anybody here help me?
asked Dec 4, 2020 Code Learner 5.5k points
0 votes
1 answer 12 views
0 votes
1 answer 52 views
Problem : I am using a SmtpClient library to send the emails using a below code : SmtpClient smtpclient = new SmtpClient(); smtpclient.Host = "hostname"; smtpclient.Port = 465; smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpclient.UseDefaultCredentials = false; smtpclient. ... port opens just fine between a client and a server. I am not sure at all what else could throw above error.
asked Jan 29, 2020 jwilliam 3.9k points