Search code examples
unity-game-enginephoton

(Unity) Display Joined Room Name? Photon PUN


I made a multiplayer game with photon unity, when a player has joined a room I want to display the name of the joined room in the scene please tell me how to do it?


Solution

  • Simply use OnJoinedRoom and get the PhotonNetwork.CurrentRoom and then its Name like e.g.

    public void OnJoinedRoom ()
    {
        var roomName = PhotonNetwork.CurrentRoom.Name;
        Debug.Log($"Joined room {roomName}");
    
        // ... However you want to display it e.g. assign it to an UI.Text or TextMeshPro etc
    }