Camera.WorldToViewportPoint and WorldToScreenPoint not correct for orthographic cameras?

Are Camera.WorldToViewportPoint () and Camera.WorldToScreenPoint () valid only for perspective cameras?

I have an orthographic camera setup for drawing GUI elements. I want GUI text to follow objects in the 3D scene. WorldToViewportPoint () and WorldToScreenPoint () do not return correct screen space values when used with an orthographic camera – the values are offset and scaled incorrectly.

These functions used with a perspective camera do give the correct results. I can switch to use it, but if this is the case, the docs should specify that these functions are only valid for perspective cameras.

Can you post your code? I’ve definitely used those functions with orthographic cameras without any problems.

Hi Garth, thank you for letting me know they have worked OK for you.

That sent me digging deeper into the setup. I suspect the problem is we are using NGUI to draw the HUD. The orthographic camera is the one being used by NGUI to render, and may be getting modified by it in an unexpected way.

I’m going to make a simple test scene without NGUI and try those functions again.