69 lines
1.6 KiB
C#
69 lines
1.6 KiB
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class BootFlowUI : MonoBehaviour
|
||
|
{
|
||
|
[Header( "Timings" )]
|
||
|
[SerializeField]
|
||
|
private float _fadeTime;
|
||
|
|
||
|
[SerializeField]
|
||
|
private float _holdTime;
|
||
|
|
||
|
[SerializeField]
|
||
|
private float _interFadeTime;
|
||
|
|
||
|
[Header("References")]
|
||
|
[SerializeField]
|
||
|
private List<CanvasGroup> _fadeGroups;
|
||
|
|
||
|
[SerializeField]
|
||
|
private SceneLoader _loader;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
StartCoroutine( Flow() );
|
||
|
}
|
||
|
|
||
|
private IEnumerator Flow()
|
||
|
{
|
||
|
float a = 0.0f;
|
||
|
|
||
|
for ( int i = 0; i < _fadeGroups.Count; ++i )
|
||
|
{
|
||
|
_fadeGroups[ i ].alpha = 0;
|
||
|
}
|
||
|
|
||
|
for ( int i = 0; i < _fadeGroups.Count; ++i )
|
||
|
{
|
||
|
a = 0f;
|
||
|
while ( a < 1f )
|
||
|
{
|
||
|
a += Time.unscaledDeltaTime / _fadeTime;
|
||
|
_fadeGroups[ i ].alpha = a;
|
||
|
yield return null;
|
||
|
}
|
||
|
|
||
|
_fadeGroups[ i ].alpha = 1f;
|
||
|
yield return new WaitForSecondsRealtime(_holdTime);
|
||
|
|
||
|
a = 1f;
|
||
|
while ( a > 0f )
|
||
|
{
|
||
|
a -= Time.unscaledDeltaTime / _fadeTime;
|
||
|
_fadeGroups[ i ].alpha = a;
|
||
|
yield return null;
|
||
|
}
|
||
|
|
||
|
_fadeGroups[ i ].alpha = 0f;
|
||
|
|
||
|
yield return new WaitForSecondsRealtime(_interFadeTime);
|
||
|
}
|
||
|
|
||
|
yield return null;
|
||
|
_loader.LoadScene( SceneType.MainMenu );
|
||
|
}
|
||
|
}
|