PhotonPlayer.SetCustomProperties C# (CSharp) Method

SetCustomProperties() public method

Updates and synchronizes the named properties of this Player with the values of propertiesToSet.
Any player's properties are available in a Room only and only until the player disconnect or leaves. Access any player's properties by: Player.CustomProperties (read-only!) but don't modify that hashtable. New properties are added, existing values are updated. Other values will not be changed, so only provide values that changed or are new. To delete a named (custom) property of this player, use null as value. Only string-typed keys are applied (everything else is ignored). Local cache is updated immediately, other players are updated through Photon with a fitting operation. To reduce network traffic, set only values that actually changed.
public SetCustomProperties ( Hashtable propertiesToSet ) : void
propertiesToSet Hashtable Hashtable of props to udpate, set and sync. See description.
return void
    public void SetCustomProperties(Hashtable propertiesToSet)
    {
        if (propertiesToSet == null)
        {
            return;
        }

        // merge (delete null-values)
        this.customProperties.MergeStringKeys(propertiesToSet); // includes a Equals check (simplifying things)
        this.customProperties.StripKeysWithNullValues();

        // send (sync) these new values
        Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
        PhotonNetwork.networkingPeer.OpSetCustomPropertiesOfActor(this.actorID, customProps, true, 0);
        NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, this);
    }

Usage Example

Beispiel #1
1
	// sets and syncs custom properties on a network player (including masterClient)
	private void SetCustomProperties(PhotonPlayer player, int car, int position) {
		ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable() { { "spawn", position }, {"car", car} };
		player.SetCustomProperties(customProperties);
	}
All Usage Examples Of PhotonPlayer::SetCustomProperties