Pun-01/Assets/Photon/PhotonUnityNetworking/Demos/PunCockpit/Scripts/ReadOnlyProperties/ServerAddressProperty.cs

42 lines
1.2 KiB
C#
Raw Permalink Normal View History

2022-07-08 09:14:55 +08:00
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RoomListView.cs" company="Exit Games GmbH">
// Part of: Pun Cockpit
// </copyright>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
namespace Photon.Pun.Demo.Cockpit
{
/// <summary>
/// PhotonNetwork.ServerAddress UI property.
/// </summary>
public class ServerAddressProperty : MonoBehaviour
{
public Text Text;
string _cache;
void Update()
{
if (PhotonNetwork.IsConnectedAndReady)
{
if (PhotonNetwork.ServerAddress != _cache)
{
_cache = PhotonNetwork.ServerAddress;
Text.text = _cache;
}
}
else
{
if (_cache != "n/a")
{
_cache = "n/a";
Text.text = _cache;
}
}
}
}
}