InternalCacheProperties









How do I use Internal Cache Properties
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: PhotonNetwork.cs Copy
1894     public static void SetPlayerCustomProperties(Hashtable customProperties)
1895     {
1896         if (customProperties == null)
1897         {
1898             customProperties = new Hashtable();
1899             foreach (object k in player.customProperties.Keys)
1900             {
1901                 customProperties[(string)k] = null;
1902             }
1903         }
1904
1905         if (room != null && room.isLocalClientInside)
1906         {
1907             player.SetCustomProperties(customProperties);
1908         }
1909         else
1910         {
1911             player.InternalCacheProperties(customProperties);
1912         }
1913     }
File name: PhotonPlayer.cs Copy
112     internal protected PhotonPlayer(bool isLocal, int actorID, Hashtable properties)
113     {
114         this.customProperties = new Hashtable();
115         this.isLocal = isLocal;
116         this.actorID = actorID;
117
118         this.InternalCacheProperties(properties);
119     }
File name: PhotonPlayer.cs Copy
152     internal void InternalCacheProperties(Hashtable properties)
153     {
154         if (properties == null || properties.Count == 0 || this.customProperties.Equals(properties))
155         {
156             return;
157         }
158
159         if (properties.ContainsKey(ActorProperties.PlayerName))
160         {
161             this.nameField = (string)properties[ActorProperties.PlayerName];
162         }
163
164         this.customProperties.MergeStringKeys(properties);
165         this.customProperties.StripKeysWithNullValues();
166     }

InternalCacheProperties 110 lượt xem

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