GetActorPropertiesForActorNr









How do I use Get Actor Properties For Actor Nr
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: NetworkingPeer.cs Copy
780     private Hashtable GetActorPropertiesForActorNr(Hashtable actorProperties, int actorNr)
781     {
782         if (actorProperties.ContainsKey(actorNr))
783         {
784             return (Hashtable)actorProperties[actorNr];
785         }
786
787         return actorProperties;
788     }

GetActorPropertiesForActorNr 116 lượt xem

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