title: OnPostRender with Multiple camera's Unity3D
body: <p>Im trying to use GL &amp; OnPostRender to render lines in Unity3D. It works fine if I just have one camera, however if I have multiple cameras (required for the oculus rift), the no matter what Ive tried, I cant get the lines to render in both camera viewports. Ive tried attaching the script to both cameras - setting the viewport etc and nothing works. If I attach the script to both cameras, then OnPostRender gets called once for each camera, but only the last one is drawn. IF I attach the script to only one camera and set the viewport to the second camera, I cant get the liones to draw in the second camera. Here is what I think should work:</p>
  
  <pre><code>Rect[] viewports;
  
              Camera[] cameras = null;
              if (Params.riftEnabled)
              {
                  viewports = new Rect[2];
                  viewports[0] = new Rect(0, 0, Screen.width / 2, Screen.height);
                  viewports[1] = viewports[0]; // new Rect(Screen.width / 2, 0, Screen.width / 2, Screen.height);
                  GameObject ovrCameraController = (GameObject)GameObject.FindGameObjectWithTag("ovrcamera");
                  cameras = (Camera[])ovrCameraController.GetComponentsInChildren&lt;Camera&gt;();
  
              }
              else
              {
                  viewports = new Rect[1];
                  viewports[0] = new Rect(0, 0, Screen.width, Screen.height);
                  cameras = new Camera[1];
                  cameras[0] = GameObject.FindObjectOfType&lt;Camera&gt;();
              }
  
              for (int i = 0; i &lt; viewports.Length; i++)
              {
                  SteeringManager.PrintVector("Cam " + i, cameras[i].transform.position);
                  GL.PushMatrix();
                  lineMaterial.SetPass(0);                                        
                  GL.modelview = cameras[i].worldToCameraMatrix;
                  GL.LoadProjectionMatrix(cameras[i].projectionMatrix);
                  GL.Viewport(viewports[i]);
                  lineMaterial.SetPass(0);
                  GL.Begin(GL.LINES);
                  foreach (Line line in lines)
                  {
                       GL.Color(line.color);
                       GL.Vertex3(line.start.x, line.start.y, line.start.z);
                       GL.Vertex3(line.end.x, line.end.y, line.end.z);
                  }
                  GL.End();
                  GL.PopMatrix();
              }
  </code></pre>