RemovePlayer
How do I use Remove Player
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
607 | void RemovePlayer(int ID, PhotonPlayer player) | 1 |
680 | RemovePlayer(actorID, player); | 2 |
File name: NetworkingPeer.cs
Copy
607 void RemovePlayer(int ID, PhotonPlayer player)
608 {
609 this.mActors.Remove(ID);
610 if (!player.isLocal)
611 {
612 RebuildPlayerListCopies();
613 }
614 }
File name: NetworkingPeer.cs
Copy
650 private void HandleEventLeave(int actorID)
651 {
652 if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
653 Debug.Log("HandleEventLeave for player ID: " + actorID);
654
655
656 // actorNr is fetched out of event above
657 if (actorID < 0 || !this.mActors.ContainsKey(actorID))
658 {
659 Debug.LogError(String.Format("Received event Leave for unknown player ID: {0}", actorID));
660 return;
661 }
662
663 PhotonPlayer player = this.GetPlayerWithID(actorID);
664 if (player == null)
665 {
666 Debug.LogError("HandleEventLeave for player ID: " + actorID + " has no PhotonPlayer!");
667 }
668
669 // having a new master before calling destroy for the leaving player is important!
670 // so we elect a new masterclient and ignore the leaving player (who is still in playerlists).
671 this.CheckMasterClient(actorID);
672
673
674 // destroy objects & buffered messages
675 if (this.mCurrentGame != null && this.mCurrentGame.autoCleanUp)
676 {
677 this.DestroyPlayerObjects(actorID, true);
678 }
679
680 RemovePlayer(actorID, player);
681
682 // finally, send notification (the playerList and masterclient are now updated)
683 SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerDisconnected, player);
684 }
RemovePlayer 118 lượt xem
Gõ tìm kiếm nhanh...