FetchFriendsFromCommunity









How do I use Fetch Friends From Community
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: GUIFriendFinding.cs Copy
10     void Start()
11     {
12         // If a user should be "findable", the client must set a playerName before connecting.
13         // This is then used during connect and the client can be found by others.
14         // Setting the playerName before connect, enables others to locate your game:
15         PhotonNetwork.playerName = "usr" + (int)Random.Range(0, 9);
16
17
18         // Photon Cloud does not implement community features for users but can work with external friends lists.
19         // We assume you get some list of IDs of your friends.
20         friendListOfSomeCommunity = FetchFriendsFromCommunity();
21
22
23         GuiRect = new Rect(Screen.width / 4, 80, Screen.width / 2, Screen.height - 100);
24     }
File name: GUIFriendFinding.cs Copy
28     public static string[] FetchFriendsFromCommunity()
29     {
30         string[] friendsList = new string[9];
31         int u = 0;
32         for (int i = 0; i < friendsList.Length; i++)
33         {
34             string usrName = "usr" + u++;
35             if (usrName.Equals(PhotonNetwork.playerName))
36             {
37                 usrName = "usr" + u++; // skip friend if the name is yours
38             }
39             friendsList[i] = usrName;
40         }
41
42         return friendsList;
43     }

FetchFriendsFromCommunity 113 lượt xem

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