using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class splashscreen : MonoBehaviour{
    public Image image;
    float op;
    [SerializeField]bool toggle, active;
    void Start(){
            op = 1f;
            StartCoroutine("wait"); 
    }
    void Update(){
            if(op > 0f && active){
            op -= 0.5f * Time.deltaTime;
            image.color = new Color (image.color.r, image.color.g, image.color.b, op);
        }
            if(op <= 0.1f && !toggle){
                toggle = true;
            }
    }
    public void OnClick(){
        StartCoroutine("CallMenu");
    }
    public IEnumerator CallMenu(){
        yield return new WaitForSeconds(2.0f);
        SceneManager.LoadScene("Select");
    }
    public IEnumerator wait(){
        yield return new WaitForSeconds(2f);
        active = true;
    }
}