i was wondering is this possible. i have gui rectangle with top left position of rPosX and rPosY. also i have the camera that rotates around objects in the scene. i wanted to have line to connect the origin of the scene (0,0,0) to the rPosX,rPosY point in the screen space.
this is how i tried to do it:
function OnPostRender(){
CreateLineMaterial();
lineMaterial.SetPass(0);
var distanceFromCamera : float= camScript.currentTarget.position.z-Camera.main.transform.position.z;
var screenPoint=Vector3(Label.rPosX,Label.rPosY,distanceFromCamera);
var worldPoint=Camera.main.ScreenToWorldPoint(screenPoint);
GL.Begin(GL.LINES);
GL.Color(Color(1,1,1,1));
GL.Vertex3(0,0,0);
GL.Vertex3(worldPoint.x,worldPoint.y,worldPoint.z);
GL.End();
}
what i am trying to do is to convert the screenPoint (rPosX,rPosY) to worldPoint and use it to render line, so that would mean that line should connect to the rectangle, but it doesnt...can somebody tell me what i am doing wrong??