chore: organized project ui structure
This commit is contained in:
parent
58ec07b1a0
commit
d6c618add0
10 changed files with 8 additions and 4 deletions
41
Assets/Scripts/View/UI/UIVisibility.cs
Normal file
41
Assets/Scripts/View/UI/UIVisibility.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using DG.Tweening;
|
||||
using Presenter;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace View.UI {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue