42 lines
700 B
C#
42 lines
700 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
public class Announcments : MonoBehaviour
|
|
{
|
|
[SerializeField] TextMeshProUGUI announcementText;
|
|
|
|
private float announcmentTime;
|
|
private float remainingTime;
|
|
|
|
void Start()
|
|
{
|
|
announcementText.enabled = false;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (remainingTime > 0)
|
|
{
|
|
if (!announcementText.enabled)
|
|
{
|
|
announcementText.enabled = true;
|
|
}
|
|
remainingTime -= Time.deltaTime;
|
|
}
|
|
else
|
|
{
|
|
announcementText.enabled = false;
|
|
remainingTime = 0;
|
|
}
|
|
}
|
|
|
|
public void AnnounceText(string text, float time)
|
|
{
|
|
announcementText.text = text;
|
|
remainingTime = time;
|
|
}
|
|
}
|