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?