mirror of
https://github.com/Kizuren/ShantiManti.git
synced 2025-12-21 21:16:04 +01:00
Refactored SceneFader and Presents script
This commit is contained in:
parent
4077334d05
commit
6f5129ec44
2 changed files with 10 additions and 13 deletions
|
|
@ -8,17 +8,14 @@ public class MarcPresents : MonoBehaviour
|
|||
public string levelToLoad = "Start";
|
||||
public float howMuchToWait = 3.0f;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(StartScene());
|
||||
}
|
||||
|
||||
IEnumerator StartScene()
|
||||
private IEnumerator StartScene()
|
||||
{
|
||||
yield return new WaitForSeconds(howMuchToWait);
|
||||
sceneFader.FadeTo(levelToLoad);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,37 +8,37 @@ public class SceneFader : MonoBehaviour {
|
|||
public Image img;
|
||||
public AnimationCurve curve;
|
||||
|
||||
void Start ()
|
||||
private void Start ()
|
||||
{
|
||||
StartCoroutine(FadeIn());
|
||||
}
|
||||
|
||||
public void FadeTo (string scene)
|
||||
public void FadeTo(string scene)
|
||||
{
|
||||
StartCoroutine(FadeOut(scene));
|
||||
}
|
||||
|
||||
IEnumerator FadeIn ()
|
||||
private IEnumerator FadeIn ()
|
||||
{
|
||||
float t = 1f;
|
||||
var t = 1f;
|
||||
|
||||
while (t > 0f)
|
||||
{
|
||||
t -= Time.deltaTime;
|
||||
float a = curve.Evaluate(t);
|
||||
var a = curve.Evaluate(t);
|
||||
img.color = new Color (0f, 0f, 0f, a);
|
||||
yield return 0;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator FadeOut(string scene)
|
||||
private IEnumerator FadeOut(string scene)
|
||||
{
|
||||
float t = 0f;
|
||||
var t = 0f;
|
||||
|
||||
while (t < 1f)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
float a = curve.Evaluate(t);
|
||||
var a = curve.Evaluate(t);
|
||||
img.color = new Color(0f, 0f, 0f, a);
|
||||
yield return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue