41 lines
No EOL
1 KiB
C#
41 lines
No EOL
1 KiB
C#
using DG.Tweening;
|
|
using Presenter;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace View {
|
|
public class UIVisibility : MonoBehaviour, IExpressionInput {
|
|
[SerializeField] private CanvasGroup ui;
|
|
[SerializeField] private float fadeDuration = .5f;
|
|
|
|
[Space]
|
|
[SerializeField] private Image titleImage;
|
|
[SerializeField] private float titleFadeDuration = 1f;
|
|
|
|
private bool _wasVisible = true;
|
|
private bool _titleVisible = true;
|
|
private Tween _fadeTween;
|
|
|
|
private void Update() {
|
|
bool isPointerOver = EventSystem.current.IsPointerOverGameObject();
|
|
|
|
if (_wasVisible && !isPointerOver) {
|
|
_fadeTween?.Kill();
|
|
_fadeTween = ui.DOFade(0, fadeDuration).SetDelay(5f);
|
|
_wasVisible = false;
|
|
} else if (!_wasVisible && isPointerOver) {
|
|
_fadeTween?.Kill();
|
|
_fadeTween = ui.DOFade(1, fadeDuration);
|
|
_wasVisible = true;
|
|
}
|
|
}
|
|
|
|
public void UpdateView(int score) {
|
|
if (!_titleVisible) return;
|
|
_titleVisible = false;
|
|
|
|
titleImage.DOFade(0, titleFadeDuration);
|
|
}
|
|
}
|
|
} |