You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CountOfPlayersInRoomProperty.cs" company="Exit Games GmbH">
// Part of: Pun Cockpit
// </copyright>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine.UI;
using Photon.Realtime;
namespace Photon.Pun.Demo.Cockpit
{
/// <summary>
/// PhotonNetwork.CountOfPlayersInRooms UI property.
/// </summary>
public class CountOfPlayersInRoomProperty : PropertyListenerBase
{
public Text Text;
int _cache = -1;
void Update()
{
if (PhotonNetwork.NetworkingClient.Server == ServerConnection.MasterServer)
{
if (PhotonNetwork.CountOfPlayersInRooms != _cache)
{
_cache = PhotonNetwork.CountOfPlayersInRooms;
Text.text = _cache.ToString();
this.OnValueChanged();
}
}
else
{
if (_cache != -1)
{
_cache = -1;
Text.text = "n/a";
}
}
}
}
}