Sorry to necro an old thread, but I'm actually trying to use this method to go the other way, and failing miserably.
I'm trying to match a world object to be at the same position on screen as the UI object, but I'm getting nowhere with this.
This is what I have so far, but it's not working at all.
myTarPos = myTarget.transform.position;
tarPosition = cam.ViewportToWorldPoint(myTarPos);
transform.position = tarPosition;
"cam" is the NGUI Camera
"myTarPos" it the UI element I'm trying to match in world space.
I hope it doesn't matter, but my NGUI cam size is "1", while my Camera.main is "4.4".