IsConnectedProperty.cs 981 B

1234567891011121314151617181920212223242526272829303132
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="IsConnectedProperty.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.IsConnected UI property
  12. /// </summary>
  13. public class IsConnectedProperty : PropertyListenerBase
  14. {
  15. public Text Text;
  16. int _cache = -1;
  17. void Update()
  18. {
  19. if ((PhotonNetwork.IsConnected && _cache != 1) || (!PhotonNetwork.IsConnected && _cache != 0))
  20. {
  21. _cache = PhotonNetwork.IsConnected ? 1 : 0;
  22. Text.text = PhotonNetwork.IsConnected ? "true" : "false";
  23. this.OnValueChanged();
  24. }
  25. }
  26. }
  27. }