Billboard world space text

We have fairly large scenes generated from data files. In the scene there are multiple static objects with labels on them (TextMesh). Currently we’re doing a lookat operation to make them face the camera and a distance operation to make them scale with the camera distance. The camera is able to move with complete freedom.

I’m looking for ideas on how to improve this as the distance operation is killing our FPS and the rotation is too. We’d like the text to always be the same size and always be facing the camera. It seems like an overlay UI would be good for this, but I don’t know how we would fix the UI in world space but always have the labels in the proper position and face the camera. A bit of a conundrum.

Thanks!

It sounds like what you are trying to achieve would be easily doable through a world-space positioned GUI element.

//A C# example
void OnGUI ()
{
    Vector2 worldPoint = Camera.main.WorldToScreenPoint (transform.position);
    GUI.Label (new Rect (worldPoint.x - 100, (Screen.height - worldPoint.y) - 50, 200, 100), "Text to display.");
}

You would just attach this script to every object that would have text, and in combination with the [ExecuteInEditMode] attribute it would work in practically all scenarios. This example works based off the “Main Camera” tagged camera but you can replace all elements in this to your needs.