ServerAddressProperty.cs 1.2 KB

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