OnPhotonPlayerPropertiesChanged









How do I use On Photon Player Properties Changed
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: NetworkingPeer.cs Copy
530     // joins a room and sets your current username as custom actorproperty (will broadcast that)
536     private void ReadoutProperties(Hashtable gameProperties, Hashtable pActorProperties, int targetActorNr)
537     {
538         // Debug.LogWarning("ReadoutProperties gameProperties: " + gameProperties.ToStringFull() + " pActorProperties: " + pActorProperties.ToStringFull() + " targetActorNr: " + targetActorNr);
539         // read game properties and cache them locally
540         if (this.mCurrentGame != null && gameProperties != null)
541         {
542             this.mCurrentGame.CacheProperties(gameProperties);
543             SendMonoMessage(PhotonNetworkingMessage.OnPhotonCustomRoomPropertiesChanged, gameProperties);
544             if (PhotonNetwork.automaticallySyncScene)
545             {
546                 this.LoadLevelIfSynced(); // will load new scene if sceneName was changed
547             }
548         }
549
550         if (pActorProperties != null && pActorProperties.Count > 0)
551         {
552             if (targetActorNr > 0)
553             {
554                 // we have a single entry in the pActorProperties with one
555                 // user's name
556                 // targets MUST exist before you set properties
557                 PhotonPlayer target = this.GetPlayerWithID(targetActorNr);
558                 if (target != null)
559                 {
560                     Hashtable props = this.GetActorPropertiesForActorNr(pActorProperties, targetActorNr);
561                     target.InternalCacheProperties(props);
562                     SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, target, props);
563                 }
564             }
565             else
566             {
567                 // in this case, we've got a key-value pair per actor (each
568                 // value is a hashtable with the actor's properties then)
569                 int actorNr;
570                 Hashtable props;
571                 string newName;
572                 PhotonPlayer target;
573
574                 foreach (object key in pActorProperties.Keys)
575                 {
576                     actorNr = (int)key;
577                     props = (Hashtable)pActorProperties[key];
578                     newName = (string)props[ActorProperties.PlayerName];
579
580                     target = this.GetPlayerWithID(actorNr);
581                     if (target == null)
582                     {
583                         target = new PhotonPlayer(false, actorNr, newName);
584                         this.AddNewPlayer(actorNr, target);
585                     }
586
587                     target.InternalCacheProperties(props);
588                     SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, target, props);
589                 }
590             }
591         }
592     }
File name: PhotonClasses.cs Copy
668         public virtual void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps)
669         {
670         }
File name: PhotonPlayer.cs Copy
184     public void SetCustomProperties(Hashtable propertiesToSet)
185     {
186         if (propertiesToSet == null)
187         {
188             return;
189         }
190
191         // merge (delete null-values)
192         this.customProperties.MergeStringKeys(propertiesToSet); // includes a Equals check (simplifying things)
193         this.customProperties.StripKeysWithNullValues();
194
195         // send (sync) these new values
196         Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
197         if (this.actorID > 0 && !PhotonNetwork.offlineMode)
198         {
199             PhotonNetwork.networkingPeer.OpSetCustomPropertiesOfActor(this.actorID, customProps, true, 0);
200         }
201         NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, this, propertiesToSet);
202     }
File name: PunTeams.cs Copy
51     public void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps)
52     {
53         this.UpdateTeams();
54     }

OnPhotonPlayerPropertiesChanged 192 lượt xem

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