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