Make a label visible for different cameras

I want a label to be visible for two cameras, but I don’t want it to be drawn twice. How can I do that? I have two players and each of them takes the Camera.main to his view (lets say third person view).

With the following script I can draw a label for each “Player”.

I have a script “DrawLabel” that looks like this:

void OnGUI(){
    GameObject [] gobjects = GameObject.FindGameObjectsWithTag ("Player");
    foreach (GameObject playerObj in gobjects) {
        Vector3 screenposition = Camera.main.WorldToScreenPoint(playerObj.transform.position);
        GUI.Label(new Rect(screenposition.x, Screen.height - (screenposition.y), 50, 50),;

When this script is attached to one player it draws the text only for him. The other player does not see the labels. But when attached to the other player, each player sees the text twice.
How can I fix that?


you could take a look into this tutorial. It explains how to use layers to render on a camera only objects of a specific layer. The video also explains how to use the Depth value of the camera to change the draw order of the cameras.