CurrentRoomNameProperty.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="CurrentRoomNameProperty.cs" company="Exit Games GmbH">
  3. // Part of: Pun Cockpit
  4. // </copyright>
  5. // <author>developer@exitgames.com</author>
  6. // --------------------------------------------------------------------------------------------------------------------
  7. using UnityEngine.UI;
  8. namespace Photon.Pun.Demo.Cockpit
  9. {
  10. /// <summary>
  11. /// PhotonNetwork.CurrentRoom.Name UI property.
  12. /// </summary>
  13. public class CurrentRoomNameProperty : PropertyListenerBase
  14. {
  15. public Text Text;
  16. string _cache = null;
  17. void Update()
  18. {
  19. if (PhotonNetwork.CurrentRoom != null)
  20. {
  21. if ((PhotonNetwork.CurrentRoom.Name != _cache))
  22. {
  23. _cache = PhotonNetwork.CurrentRoom.Name;
  24. Text.text = _cache.ToString();
  25. this.OnValueChanged();
  26. }
  27. }
  28. else
  29. {
  30. if (_cache == null)
  31. {
  32. _cache = null;
  33. Text.text = "n/a";
  34. }
  35. }
  36. }
  37. }
  38. }