Global Game Jam 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

77 lines
1.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;
public class HowToPlayController : MonoBehaviour
{
[SerializeField]
private MaskableGraphic[] graphics;
[SerializeField]
private float fadeTime = 1.0f;
[SerializeField]
private float showTime = 3;
[SerializeField]
private string NextLevel = "Level 1";
IEnumerator Start()
{
float elapsedTime = 0;
Color color;
while (elapsedTime < fadeTime)
{
foreach(MaskableGraphic g in graphics)
{
color = g.color;
color.a = elapsedTime / fadeTime;
g.color = color;
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
}
foreach (MaskableGraphic g in graphics)
{
color = g.color;
color.a = 1;
g.color = color;
}
yield return new WaitForSeconds(showTime);
elapsedTime = 0;
while (elapsedTime < fadeTime)
{
foreach (MaskableGraphic g in graphics)
{
color = g.color;
color.a = 1 - elapsedTime / fadeTime;
g.color = color;
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
}
foreach (MaskableGraphic g in graphics)
{
color = g.color;
color.a = 0;
g.color = color;
}
SceneManager.LoadScene(NextLevel);
}
}