0
votes

I am using Photon PUN with Unity. I have some static classes that track player data in my game. Here is an example of a method to update data...

public static void IsSeated(bool value)
{
    Room room = PhotonNetwork.room;
    Hashtable PlayerSeat1 = new Hashtable();
    object[] seat1 = (object[])room.customProperties["seat1"];
    seat1[0] = value;
    PlayerSeat1.Add("seat1", seat1);
    room.SetCustomProperties(PlayerSeat1);
}

The problem is when I update this hashtable all my other room data is over written with the changes. All of my hashtables have distinct keys. I would greatly appreciate any help.

1

1 Answers

0
votes

I have resolved this issue...And it may be of interest to anyone using Photon Pun with Hashtables and Room data

When I initialized all of the hash table data during an Initialization method I was doing something like this...

Room room = PhotonNetwork.room;

        object[] data = new object[]{with data inside};   


        Hashtable GameData1 = new Hashtable();
        GameData1.Add("data1", data);

        Hashtable GameData2= new Hashtable();
        GameData2.Add("data2", data);

        room.SetCustomProperties(GameData1);
        room.SetCustomProperties(GameData2);

Then when I would update any Room data it would overwrite all of my data even though I had distinct keys...

But when I initialize it like this...

Room room = PhotonNetwork.room;

        object[] first_data = new object[]{with data inside};   
        object[] second_data = new object[]{with data inside}; 

        Hashtable GameData1 = new Hashtable();
        GameData1.Add("data1", first_data);

        Hashtable GameData2= new Hashtable();
        GameData2.Add("data2", second_data);

        room.SetCustomProperties(GameData1);
        room.SetCustomProperties(GameData2);

it updates normally and does not overwrite any other Hashtables...