Hi guys,
its been a few months since i started iphone dev and unity. iv been hanging around the forums, reading posts from other people, really just to help me in dev.
Recently i encountered a problem with converting points from 3D to 2D. This is the code:
point3D = myMesh.mesh.vertices[3];
Debug.Log("point3D = " + point3D);
point2D = Camera.allCameras[0].WorldToScreenPoint(m_transform.TransformPoint(point3D));
Debug.Log("point2D = " + point2D);
now when i run this in pc(editor window) i get this values:
for point 3D, i get -10.0, 0.0, -10.0
for point 2D, i get 182.8, 44.7
but when i run this on an iPhone i get these:
for point 3D, i get -10.0, 0.0, -10.0
for point 2D, i get 74.2, 67.0
question is, why?
edit: removed images as it doesn’t work
http://tvntww.bay.livefilestore.com/y1pmOmC9CWz1z1bd1Fvd1ST0O8WXM4zvC33mgILRtQH5UBIRG4Gr0QT-W-5NtR1ImAEDi9TrLQYbrT557pQnLpO0Q/img2.tiff
http://tvntww.bay.livefilestore.com/y1p0s7DlVu_iTLWVH3aMfg551FxofxZbxXVeB3CWUQleEAghQWmm0CTOa91HhZOyDEloz5FaM5tH6xmmNrIMmOO_A/img1.tiff
is your game screen set to an identical resolution? 
woah! thanks for the fast rep. 
ok.
hmm… i just recently updated my unity to 1.5. m not sure where i found it but m pretty sure i made it to the same resolution when i stumbled upon it last week. m double checking right now.
edit:
ok, so the res change is not available in the unity iPhone project settings->player (duh!). on an irrelevant point, i set the unity pc player res to 320x480. 
m still having the problems!
i seem to remember running to the same problem back when i was having performance issues for a prototype build. m giong to try unloading my scene later this afternoon and see if the problem persists.
Hi guys,
Have you guys figure this out? I’m having a similar problem. The result of the WorldToScreenPoint is not good. It also seems to be the case for WorldToViewportPoint (wich I guess it normal since I’m pretty sure that WorldToScreenPoint is using WorldToViewportPoint).
I’m using this function to create a rect around a gameobject using it’s bounds GameObject.renderer.bounds. But the rect is far from over the object.
I’m using Unity 1.5.
Here’s the relevant code:
Vector2 center = mm.gameObject.camera.WorldToScreenPoint(m_robot.renderer.bounds.center);
Vector2 min = mm.gameObject.camera.WorldToScreenPoint(m_robot.renderer.bounds.min);
Vector2 max = mm.gameObject.camera.WorldToScreenPoint(m_robot.renderer.bounds.max);
float left = min.x;
float top = min.y;
float width = Mathf.Abs( max.x - min.x );
float height = Mathf.Abs( max.y - min.y );
Rect testRect = new Rect(left, top, width, height);
GUI.Button(testRect, “Hello”); //This is far from over the object and I don’t know why
If you guys found anything, I’m very interested.
hi dude,
well i don’t know about the bounds thing but i was able to make it work by fixing my fps. previously it ran very slowly, under 10 fps. but after i optimized my code the returned values started to be much closer to the one on editor.