using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class FadeOutController : MonoBehaviour
{
    public Image fadeImage; // UI Image (Canvas üzerindeki Image)
    public float fadeDuration = 1f; // Fade süresi (saniye)

    private void Start()
    {
        StartCoroutine(FadeOut());
    }

    private IEnumerator FadeOut()
    {
        yield return new WaitForSeconds(5f);
        float elapsedTime = 0f;
        Color color = fadeImage.color;

        while (elapsedTime < fadeDuration)
        {
            elapsedTime += Time.deltaTime;
            color.a = Mathf.Clamp01(elapsedTime / fadeDuration); // Alfa değerini artır
            fadeImage.color = color;
            yield return null;
        }

        // Alfa değerini tamamen 1 yap (tamamen görünür hale getir)
        color.a = 1;
        fadeImage.color = color;
    }
}
