Need GUI visible only to each player

I downloaded the free Photon Multiplayer Viking game and I want to add a GUI for each player. I added a disabled prefab to my player that activates when the player spawns but the GUI attached to it will appear to the other players. I need each player's GUI visible only to themselves. How do I segregate the GUIs to each player?


  • I'm just learning aswell.

    But I think I can help you out.

    If you have each player instaniated when they join. I assume you have your GUI script attached to your player prefab aswell.

    To have your GUI only visible to YOUR player, and not others. Simply add this bit of code.

    [code2=csharp]if (photonView.isMine)
    Your code here
    In this case, your GUI is only being drawn if the PhotonView is yours.

    Here's another example, that I personally use for my game.
    It's a simple script that changes the player's color when the button is clicked.

    [code2=csharp]void OnGUI()
    if (photonView.isMine)
    GUI.contentColor =;
    if (GUI.Button(new Rect(0, 20, 50, 30), "Red"))
    police = false;
    photonView.RPC("ColorRed", PhotonTargets.AllBuffered, null);

    public void ColorRed()
    gameObject.renderer.material.color =;
    Hope this helps ya!
  • I felt good about that but I get this compile error:
    The name `photonView' does not exist in the current context
  • If you're getting that error.

    You need to change
    [code2=csharp]public class YOUR SCRIPT NAME : MonoBehaviour[/code2]
    Located at the top of the script.

    Change it to

    [code2=csharp]public class YOUR SCRIPT NAME : Photon.MonoBehaviour[/code2]
    That should fix your issue.

    I also recommend reading through the official photon documentation, and maybe even following the Marco Polo tutorial. ... marco-polo

    Hope this helps ya!
Sign In or Register to comment.