using Fie.Utility;
using Spine.Unity;
using UnityEngine;
using UnityEngine.UI;
namespace Fie.Fader
{
///
/// Fader used to white out the screen whilst the game is loading.
///
public class FieFader : MonoBehaviour
{
[SerializeField]
private GameObject faderCameraRootObject;
[SerializeField]
private Image faderPlaneObject;
///
/// The loading icon that appears in the lower right corner.
///
[SerializeField]
private SkeletonGraphic _loadingIcon;
private Tweener faderTweener = new Tweener();
///
/// True if the loading screen is currently visible.
///
private bool isDrawFader;
public void Initialize() {
faderCameraRootObject.transform.gameObject.SetActive(value: false);
}
public void HideFader() {
isDrawFader = false;
faderCameraRootObject.transform.gameObject.SetActive(value: false);
}
///
/// Creates this view, sets it to visible, and starts showing the loading screen.
///
public void InitFader(Vector4 startColor, Vector4 endColor, float time) {
isDrawFader = true;
faderTweener.InitTweener(time, startColor, endColor);
faderCameraRootObject.transform.gameObject.SetActive(value: true);
}
///
/// Checks if the loading screen is still fading in/our and returns false otherwise.
///
public bool IsEndUpdateFader() {
return faderTweener == null || faderTweener.IsEnd();
}
///
/// Draws the loading screen. Currently just a plain white background.
///
private void Update() {
if (isDrawFader) {
Color color = faderTweener.UpdateParameterVec4(Time.deltaTime);
faderPlaneObject.color = color;
_loadingIcon.color = new Color(1f, 1f, 1f, color.a);
}
}
public void ShowLoadScreen() {
// TODO: Implement this
}
public void HideLoadScreen() {
// TODO: Implement this
}
}
}