Guest
How do I use Guest
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
58 | PhotonNetwork.playerName = "Guest" + Random.Range(1, 9999); | 1 |
File name: WorkerMenu.cs
Copy
43 public void Awake()
44 {
45 // this makes sure we can use PhotonNetwork.LoadLevel() on the master client and all clients in the same room sync their level automatically
46 PhotonNetwork.automaticallySyncScene = true;
47
48 // the following line checks if this client was just created (and not yet online). if so, we connect
49 if (PhotonNetwork.connectionStateDetailed == PeerState.PeerCreated)
50 {
51 // Connect to the photon master-server. We use the settings saved in PhotonServerSettings (a .asset file in this project)
52 PhotonNetwork.ConnectUsingSettings("0.9");
53 }
54
55 // generate a name for this player, if none is assigned yet
56 if (String.IsNullOrEmpty(PhotonNetwork.playerName))
57 {
58 PhotonNetwork.playerName = "Guest" + Random.Range(1, 9999);
59 }
60
61 // if you wanted more debug out, turn this on:
62 // PhotonNetwork.logLevel = NetworkLogLevel.Full;
63 }
Guest 127 lượt xem
Gõ tìm kiếm nhanh...