feat: hide title when game starts
This commit is contained in:
parent
0bed7bbea4
commit
58ec07b1a0
5 changed files with 42 additions and 8 deletions
|
@ -1,31 +1,41 @@
|
|||
using System;
|
||||
using DG.Tweening;
|
||||
using Presenter;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace View {
|
||||
public class UIVisibility : MonoBehaviour {
|
||||
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;
|
||||
return;
|
||||
}
|
||||
if (!_wasVisible && isPointerOver) {
|
||||
} else if (!_wasVisible && isPointerOver) {
|
||||
_fadeTween?.Kill();
|
||||
_fadeTween = ui.DOFade(1, fadeDuration);
|
||||
_wasVisible = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateView(int score) {
|
||||
if (!_titleVisible) return;
|
||||
_titleVisible = false;
|
||||
|
||||
titleImage.DOFade(0, titleFadeDuration);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue