WinterJamSnowman/Assets/Scripts/LemonGenericLib/SceneManagement/TransitionUI.cs

55 lines
1.6 KiB
C#
Raw Normal View History

2023-01-24 13:51:46 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Lemon.GenericLib.SceneManagement
{
public class TransitionUI : MonoBehaviour
{
[SerializeField] private CanvasGroup canvasGroup;
[SerializeField] private bool useDefaultFadeTransition;
[SerializeField] public float effectDuration;
[SerializeField] private LeanTweenType fadeEffectType;
//[SerializeField] float threshold;
//[SerializeField] float rate;
//[SerializeField] GameObject transitionObject;
private float targetAlpha = 1;
public void TransitionAnimationEnter()
{
targetAlpha = 0;
if (useDefaultFadeTransition)
{
canvasGroup.LeanAlpha(targetAlpha, effectDuration).setEase(fadeEffectType).setOnComplete(() => { canvasGroup.blocksRaycasts = false; });
return;
}
}
public void TransitionAnimationExit()
{
targetAlpha = 1;
if (useDefaultFadeTransition)
{
canvasGroup.LeanAlpha(targetAlpha, effectDuration).setEase(fadeEffectType).setOnComplete(() => { canvasGroup.blocksRaycasts = true; });
return;
}
}
//float alpha = 0;
//public void Update() {
// alpha = canvasGroup.alpha;
// alpha = Mathf.Lerp(alpha, targetAlpha, rate * Time.deltaTime);
// canvasGroup.alpha = alpha;
// canvasGroup.blocksRaycasts = (alpha > threshold);
//}
}
}