title: PUN 2 Getting Custom Properties
body: <p>I've recently taken on the task of custom properties in Photon. I have been able to figure out how to <em>set</em> the custom properties, but not <em>get</em> the custom properties. My hashtable is in my player controller script, while the place where I set (and where I want to get) properties is in a round loop script.</p>
  
  <p>From RoundSystem:</p>
  
  <pre><code>private IEnumerator TeamBalance()
      {
          angelCount = Mathf.Floor(PhotonNetwork.PlayerList.Length * angelPercent);
          currentAngels = angelCount;
          currentPlayers = PhotonNetwork.PlayerList.Length;
  
          foreach (var item in PhotonNetwork.PlayerList)
          {
              var itemPhotonView = (PhotonView)item.TagObject;
  
              itemPhotonView.RPC("SetPlayerTeam", item, citiString);
          }
  
          for (int i = 0; i &lt; angelCount;)
          {
              var item = PhotonNetwork.PlayerList[Random.Range(0, PhotonNetwork.PlayerList.Length)];
              var itemPhotonView = (PhotonView)item.TagObject;
  
              if (/* random player selected's, AKA, item's team == citiString */)
              {
                  itemPhotonView.RPC("SetPlayerTeam", item, angelString);
  
                  i++;
              }
          }
  
          yield return null;
          //the reason this is in an IEnumerator with 'yield return null'
          //is because I plan to add a waiting period once I figure this out
          //it's for the game loop
      }
  </code></pre>
  
  <p>From PlayerController:</p>
  
  <pre><code>[PunRPC]
          public void SetPlayerTeam(string teamString)
          {
              //in the class:     private ExitGames.Client.Photon.Hashtable playerProperties; 
              if (!playerProperties.ContainsKey("team"))
              {
                  playerProperties.Add("team", teamString);
              }
              playerProperties["team"] = teamString;
              PhotonNetwork.LocalPlayer.SetCustomProperties(playerProperties);
          }
  </code></pre>
  
  <p>At the beginning of the round, a percentage (in this case 1/3) of players are chosen to be an "angel". The check here is needed because in cases of multiple angels, you don't want an already existing angel to count as a new change. (Also, it's probably important to known generally how to get custom properties if I'm going to be using them.) If I don't include the check in RoundSystem, the outcome is 2 citizens and 1 angel (in a test with 3 players). Also, if you see any spaghetti code that could be improved on, please don't hesitate to tell me. :)</p>