SetMiniGame.cs
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class SetMiniGame : MonoBehaviour
{
static public SetMiniGame Instance;
public GameObject UIButton;
public Image backPanel;
private Color m_color;
private float fadeTime = 1f;
float start;
float end;
float time = 0f;
private void Awake()
{
Instance = this;
}
public void SetButton(bool open)
{
UIButton.SetActive(open);
}
public void StartMiniGameScene()
{
StartCoroutine(ImageFadeOut());
}
protected IEnumerator ImageFadeOut()
{
m_color.a = 0f;
m_color = backPanel.color;
start = 0f; end = 1f; time = 0f;
backPanel.gameObject.SetActive(true);
while (m_color.a < 1f)
{
time += Time.deltaTime / fadeTime;
m_color.a = Mathf.Lerp(start, end, time);
backPanel.color = m_color;
yield return null;
}
SceneManager.LoadScene("MiniGameScene");
}
}