IsInRoom









How do I use Is In Room
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: GUIFriendFinding.cs Copy
52     public void OnGUI()
53     {
54         if (!PhotonNetwork.insideLobby)
55         {
56             // this feature is only available on the Master Client. Check either: insideLobby or
57             // PhotonNetwork.connectionStateDetailed == PeerState.Authenticated or
58             // PhotonNetwork.connectionStateDetailed == PeerState.JoinedLobby
59
60             // for simplicity (and cause we know we WILL join the lobby, we can just check that)
61             return;
62         }
63
64
65         GUILayout.BeginArea(GuiRect);
66
67         GUILayout.Label("Your (random) name: " + PhotonNetwork.playerName);
68         GUILayout.Label("Your friends: " + string.Join(", ",this.friendListOfSomeCommunity));
69
70
71         GUILayout.BeginHorizontal();
72         if (GUILayout.Button("Find Friends"))
73         {
74             PhotonNetwork.FindFriends(this.friendListOfSomeCommunity);
75         }
76         if (GUILayout.Button("Create Room"))
77         {
78             PhotonNetwork.CreateRoom(null); // just a random room
79         }
80         GUILayout.EndHorizontal();
81
82
83         if (PhotonNetwork.Friends != null)
84         {
85             foreach (FriendInfo info in PhotonNetwork.Friends)
86             {
87                 GUILayout.BeginHorizontal();
88                 GUILayout.Label(info.ToString());
89                 if (info.IsInRoom)
90                 {
91                     if (GUILayout.Button("join"))
92                     {
93                         PhotonNetwork.JoinRoom(info.Room);
94                     }
95                 }
96                 GUILayout.EndHorizontal();
97             }
98         }
99
100         GUILayout.EndArea();
101     }
File name: FriendInfo.cs Copy
10     public bool IsInRoom { get { return IsOnline && !string.IsNullOrEmpty(this.Room); } }
File name: FriendInfo.cs Copy
12     public override string ToString()
13     {
14         return string.Format("{0}\t is: {1}", this.Name, (!this.IsOnline) ? "offline" : this.IsInRoom ? "playing" : "on master");
15     }

IsInRoom 110 lượt xem

Gõ tìm kiếm nhanh...