IsConnectedAndReadyProperty.cs 1.0 KB

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