您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

34 行
1.2 KiB

using UnityEngine;
using Unity.Netcode;
namespace LobbyRelaySample.ngo
{
/// <summary>
/// Displays the results for all players after the NGO minigame.
/// </summary>
public class ResultsUserUI : NetworkBehaviour
{
[Tooltip("The containers for the player data outputs, in order, to be hidden until the game ends.")]
[SerializeField] private CanvasGroup[] m_containers;
[Tooltip("These should be in order of appearance, i.e. the 0th entry is the 1st-place player, and so on.")]
[SerializeField] private TMPro.TMP_Text[] m_playerNameOutputs;
[Tooltip("These should also be in order of appearance.")]
[SerializeField] private TMPro.TMP_Text[] m_playerScoreOutputs;
private int m_index = 0;
public void Start()
{
foreach (var container in m_containers)
container.alpha = 0;
}
// Assigned to an event in the Inspector.
public void ReceiveScoreInOrder(PlayerData data)
{
m_containers[m_index].alpha = 1;
m_playerNameOutputs[m_index].text = data.name;
m_playerScoreOutputs[m_index].text = data.score.ToString("00");
m_index++;
}
}
}