-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControllerFade.cs
73 lines (54 loc) · 1.67 KB
/
ControllerFade.cs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class ControllerFade : MonoBehaviour
{
[Header("Componentes")]
public static ControllerFade _instanciaFade;
private FimFase _FimFase;
public Image _imagemFade;
[Header("Cores do Fade")]
public Color _corInicial;
public Color _corFinal;
public Color _corInicial2;
public Color _corFinal2;
[Header("Configurações do Fade")]
public float _duracaoFade;
public bool _isFade;
private float _tempo;
// Start is called before the first frame update
void Awake()
{
_instanciaFade = this;
}
public IEnumerator inicioFade(){
_isFade = true;
_tempo = 0f;
while(_tempo <= _duracaoFade){
_imagemFade.color = Color.Lerp(_corInicial, _corFinal, _tempo / _duracaoFade);
_tempo = _tempo + Time.deltaTime;
yield return null;
}
_isFade = false;
}
public IEnumerator FinalFade(){
_isFade = true;
_tempo = 0f;
while(_tempo <= _duracaoFade){
_imagemFade.color = Color.Lerp(_corInicial2, _corFinal2, _tempo / _duracaoFade);
_tempo += Time.deltaTime;
yield return null;
}
_isFade = false;
}
void Start()
{
StartCoroutine(inicioFade());
}
// Update is called once per frame
void Update()
{
}
}