- Home /
Graphics.DrawMeshNow on top of gui elements
Hi,
Consider the following code on a gameobject with a cube attached to it, but the renderer is disabled. The purpose of this code is to just display the cube.
void OnGUI()
{
if (Event.current.type == EventType.repaint)
{
GetComponent<MeshRenderer>().material.SetPass(0);
Graphics.DrawMeshNow(GetComponent<MeshFilter>().sharedMesh,
Matrix4x4.identity);
}
}
This code doesn't display anything. It does display the cube if the filtered event type is EventType.layout. However, if I use that event, GUI elements (buttons, labels etc) will get rendered on top of me, which is not what I aim to achieve.
I tried using camera.current.transform and the similar functions do get this to work, but couldn't.
Is there a way to have Graphics.DrawMeshNow render things to the screen after (or during) the GUI repaint process?
Answer by magnuskoch · Apr 11, 2013 at 10:29 PM
Even though your question is old, I´m leaving some input for other people struggling with this.
As far as i can see, Graphics.DrawMeshNow can only be called from the OnPostRender function of a script attached to a camera,
Your answer
Follow this Question
Related Questions
Drawing a screen space rectangle with Graphics.DrawMeshNow 1 Answer
GUI Texture Resolution 0 Answers
Where to call Graphics.DrawMesh to successfully draw during editor pause? 0 Answers
Graphics.DrawMesh not working 2 Answers
How many tris is required to port in all iphone and android devices 1 Answer