Basic Networking done

This commit is contained in:
2022-01-26 19:10:12 +05:30
parent d852b2bb2c
commit 891318680d
1111 changed files with 105855 additions and 780 deletions

View File

@@ -0,0 +1,44 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace Mirror.Examples.MultipleMatch
{
public class MatchGUI : MonoBehaviour
{
Guid matchId;
[Header("GUI Elements")]
public Image image;
public Toggle toggleButton;
public Text matchName;
public Text playerCount;
[Header("Diagnostics - Do Not Modify")]
public CanvasController canvasController;
public void Awake()
{
canvasController = FindObjectOfType<CanvasController>();
toggleButton.onValueChanged.AddListener(delegate { OnToggleClicked(); });
}
public void OnToggleClicked()
{
canvasController.SelectMatch(toggleButton.isOn ? matchId : Guid.Empty);
image.color = toggleButton.isOn ? new Color(0f, 1f, 0f, 0.5f) : new Color(1f, 1f, 1f, 0.2f);
}
public Guid GetMatchId()
{
return matchId;
}
public void SetMatchInfo(MatchInfo infos)
{
matchId = infos.matchId;
matchName.text = "Match " + infos.matchId.ToString().Substring(0, 8);
playerCount.text = infos.players + " / " + infos.maxPlayers;
}
}
}