title: Photon Network Player.SetCustomProperties not working
body: <p>I am currently building an online game with Photon Networking using Unity and I have a problem with <a href="https://doc-api.photonengine.com/en/pun/v2/class_photon_1_1_realtime_1_1_player.html#a73265fc7665581640574dc7e98526c77" rel="nofollow noreferrer">Photon.Realtime.Player.SetCustomProperties()</a> method. I've already googled it but I couldn't find anything like my issue.</p>
  <h2>About the project</h2>
  <p>The matchmaking system is nothing very fancy: I have a first scene to login (without password for now), that will connect to Photon. When <code>OnConnectedToMaster</code> event is raised I load the lobby scene that will display the rooms. And finally, when <code>OnJoinedRoom</code> is called I load a 3rd scene for the room itself, it will display the players, set teams, game config, etc.</p>
  <p>I've made an extension class both for <a href="https://doc-api.photonengine.com/en/pun/v2/class_photon_1_1_realtime_1_1_player.html" rel="nofollow noreferrer">Player</a> and <a href="https://doc-api.photonengine.com/en/pun/v2/class_photon_1_1_realtime_1_1_room_info.html" rel="nofollow noreferrer">Room</a> (RoomInfo) classes to make it easier and clean to get/set the Custom Properties.</p>
  <h2>The issue</h2>
  <p>As soon as I load the Room scene I want to get a few properties from the Player to display in the Room, like MMR (ranking), for example. So I made the following code:</p>
  <pre><code>public static class PlayerExtensions
  {
      private static readonly string _mmrProperty = &quot;mmr&quot;;
  
      public static void SetMmr(this Player player, int mmr)
      {
          player.SetCustomProperties(new Hashtable() { { _mmrProperty, mmr.ToString() } });
      }
  
      public static int GetMmr(this Player player)
      {
          return (int)player.CustomProperties[_mmrProperty];
      }
  }
  </code></pre>
  <p>After getting null exception error on <code>GetMmr()</code> I realized the player doesn't have the actual 'mmr' Custom Property in it. So I debugged the <code>SetMmr()</code> and I noticed a few things:</p>
  <ul>
  <li>the player already have some custom properties that I never set, called &quot;name&quot; and &quot;hideFlags&quot;.</li>
  <li><code>SetCustomProperties()</code> doesn't do anything at all. I was expecting it to create/change the 'mmr' property, but it doesn't</li>
  <li>If I directly change <code>player.CustomProperties</code> it works. However it doesn't seem to be the right approach.</li>
  </ul>
  <p>This is me debugging it on 3 steps: <a href="https://imgur.com/a/YI24dP0" rel="nofollow noreferrer">https://imgur.com/a/YI24dP0</a></p>
  <p>So, I am not sure what to do next since the <code>SetCustomProperties()</code> doesn't seem to work.
  Any ideas? Thanks.</p>