using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Fade : MonoBehaviour
{
    private CanvasGroup m_canvas;
    private float m_fade = 1.0f;
    private bool m_bControl = true;
    // Start is called before the first frame update
    void Start()
    {
        m_canvas = gameObject.GetComponent<CanvasGroup>();
    }

    // Update is called once per frame
    void Update()
    {
        if(m_bControl)
        {
            m_fade -= Time.deltaTime;
            if (m_fade <= 0.4f)
            {
                m_bControl = false;
            }
        }
        else
        {
            m_fade += Time.deltaTime;
            if (m_fade >= 1.0f)
            {
                m_bControl = true;
            }
        }
        m_canvas.alpha = m_fade;
    }
}
