using UnityEngine;
using System.Collections;

public class DisplayTextWhenClick : MonoBehaviour
{
    [SerializeField] private GameObject popupUI;
    [SerializeField] private float displayTime = 3f;

    private bool isShowing = false;

    private void OnMouseDown()
    {
        if (!isShowing)
        {
            StartCoroutine(ShowPopup());
        }
    }

    private IEnumerator ShowPopup()
    {
        isShowing = true;
        popupUI.SetActive(true);

        yield return new WaitForSeconds(displayTime);

        popupUI.SetActive(false);
        isShowing = false;
    }
}
