- Home /
unity3d android gui flickering rendertexture GL.Clear
Hi,
I have a problem with GUI flickering on any key or mouse input when GUI is rendered in script in OnGUI method with render texture active set to texture. Then this render texture is attached to material added to Quad in front of standard camera. shader does not matter, tried any even simple diffuse.
It is happening if following is met
OnGUI has set active render texture and any GUI is rendered to this texture. RenderTexture.active=mytexture;
There is GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 1.0f)); in the OnGUI to clear render texture. Funny enough the flicker is present if color is with Alpha value (can be any alpha value even 1.0) but it is not present when using Color.black for example.
If I call GL.Clear in every OnGUI call GUI is drawn properly on texture and flickering is happening only when you press any key or mouse button. If I call GL.Clear like every half a second, then flicker is present every half a second on each clear and it does not happen on key or mouse press anymore.
it is happening when project is switched to Android. If I run the same in editor on Mac with project set as standalone flickering can be seen in scene view but not in the Game view.
I'm running out of ideas how to solve this. I ned this working on Android and with alpha color clear of GL. On joystick input this flicker is very annoying.
Here is simple empty project with just 2 objects in scene to demonstrate this. Make sure you switch project to Android before running in editor and then press key on keyboard when running. https://dl.dropboxusercontent.com/u/22506069/uiRenderTextflicker.zip
Just to note, I'm running on latest OSx 10.10 something and latest Unity pro 4.6.1f1
I appreciate any ideas. Thanks.
+++ Update +++
Here is a screen recording of the problem https://dl.dropboxusercontent.com/u/22506069/guiFlicker.mov
and here is a code of only script in the scene
using UnityEngine;
using System.Collections;
public class renderGUI : MonoBehaviour {
public RenderTexture rentext;
private float lastCleared = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
RenderTexture.active=rentext;
//if (Time.time-lastCleared>0.005f){
GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 1.0f));
// lastCleared=Time.time;
//}
GUI.Button(new Rect(50,50,300,100),"Hayyyyy");
RenderTexture.active=null;
}
}
Is there anyone drawing UI on texture? is this happening only to me or is the sample project giving same result to you as well?
Your answer
Follow this Question
Related Questions
Unity 5 GUI fllickering, artefacts on Android 3 Answers
Text To Texture/Image 1 Answer
Android Options Menu 0 Answers
Is there a way to scroll GUI text WITHOUT scrollbars? 2 Answers