Hi There,
I am a bit stuck with the following problem:
I am trying to get a line renderer working by creating a world object from mouse/touch screen coordinates (screenToWorldPoint). For debugging I use a GUITexture, displaying the coordinates. Problem is, that when I use camera.current, the counter updates fine only in scene view (not game view window) (but the usual problems with the camera.current being sometimes null occur) → so naturally i use camera.main, but then the counter stops updating completely (i only get a single first value)… no idea what i am doing wrong here (using os x lion for testing)
script for the mouse coordinate to world coordinate conversion and counter display
var text : GUIText;
function Update () {
var mpos : Vector3 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
text.text = "X:"+mpos.x+" - Y:"+mpos.y;
}
[Edit:] Simplification
Script attached to an empty GameObject in the scene:
function Update() {
Debug.Log("world:"+Camera.main.ScreenToWorldPoint(Input.mousePosition)); //no updates
Debug.Log("screen:"+Input.mousePosition); //updates fine
}