- Home /
Question by
flamy · Oct 01, 2012 at 10:53 AM ·
guiopenglonpostrender
Coordinate woe OnPostRender/OnGUI, immediate draw?
"Coordinate system changes between OnPostRender and OnGUI while in immediate draw mode"
Hi, i am running in to a strange problem, where The co-ordinate system changes completly between OnPostRender and OnGUI of the same script. It seems like OnPostRender follows World coordinate system and OnGUI follows Screen coordinate system.
I guess u will understand from the following code,
void OnPostRender()
{
if(Event.current.type == EventType.repaint)
DrawCircle();
}
void OnGUI()
{
DrawCircle();
}
void DrawCircle()
{
zValue = transform.position.z+1;
GL.Begin(GL.LINES);
GL.Color( new Color(1,0,1,1f) );
for(int i=1;i<360;i+=6)
{
GL.Vertex3 ( 0 + Mathf.Cos ((i-1)*Mathf.Deg2Rad)*radius, 0 + Mathf.Sin((i-1)*Mathf.Deg2Rad)*radius,zValue);
GL.Vertex3 ( 0 + Mathf.Cos (i*Mathf.Deg2Rad)*radius, 0 + Mathf.Sin(i*Mathf.Deg2Rad)*radius,zValue);
}
GL.End();
}
this script is attached to an orthographic camera, where i am getting 2 different circles. one at the top of the screen and one at the middle of various size, though the radius is the same.
Is it a bug or is this the way GL functions work in unity. Is there a possibility of making it use one fixed co ordinate system.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613081723im_/https://answers.unity.com/themes/thub/images/avi.jpg)