You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
910 B
C#
45 lines
910 B
C#
3 days ago
|
using Unity.Netcode;
|
||
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
|
||
|
|
||
|
public class WarningPanel : NetworkBehaviour
|
||
|
{
|
||
|
public static WarningPanel Instance { get; private set; }
|
||
|
|
||
|
[SerializeField] private GameObject panel;
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
if (Instance == null)
|
||
|
{
|
||
|
Instance = this;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Destroy(gameObject);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void ShowPanelForTime(float seconds)
|
||
|
{
|
||
|
if (IsServer) // Only the server should trigger this
|
||
|
{
|
||
|
ShowPanelClientRpc(seconds);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[ClientRpc]
|
||
|
private void ShowPanelClientRpc(float seconds)
|
||
|
{
|
||
|
panel.SetActive(true);
|
||
|
StartCoroutine(HidePanelAfterTime(seconds));
|
||
|
}
|
||
|
|
||
|
private IEnumerator HidePanelAfterTime(float seconds)
|
||
|
{
|
||
|
yield return new WaitForSeconds(seconds);
|
||
|
panel.SetActive(false);
|
||
|
}
|
||
|
}
|