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); } }