chore: organized project ui structure
This commit is contained in:
parent
58ec07b1a0
commit
d6c618add0
10 changed files with 8 additions and 4 deletions
20
Assets/Scripts/View/UI/CloseButton.cs
Normal file
20
Assets/Scripts/View/UI/CloseButton.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace View.UI {
|
||||
public class CloseButton : MonoBehaviour {
|
||||
private Button _button;
|
||||
|
||||
private void Start() {
|
||||
_button = GetComponent<Button>();
|
||||
_button.onClick.AddListener(CloseClicked);
|
||||
}
|
||||
|
||||
private void CloseClicked() {
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("Quit");
|
||||
#endif
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/View/UI/CloseButton.cs.meta
Normal file
11
Assets/Scripts/View/UI/CloseButton.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f297a9343fac1cf42b0de26c43db994f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
49
Assets/Scripts/View/UI/ExpressionInput.cs
Normal file
49
Assets/Scripts/View/UI/ExpressionInput.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using Domain;
|
||||
using Domain.Input;
|
||||
using Presenter;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace View.UI {
|
||||
public class ExpressionInput : MonoBehaviour, IExpressionInput {
|
||||
[SerializeField] private TMP_Text text;
|
||||
private ExpressionClick _click;
|
||||
private CustomInput _customInput;
|
||||
|
||||
private void Start() {
|
||||
_click = FindObjectOfType<Dependencies>().ExpressionClick;
|
||||
_customInput = FindObjectOfType<Dependencies>().CustomInput;
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
CheckInput();
|
||||
}
|
||||
|
||||
private void CheckInput() {
|
||||
_customInput.UpdateInput();
|
||||
|
||||
if (_customInput.KeyDown(typeof(GeminadaReader)))
|
||||
_click.Execute();
|
||||
if (_customInput.KeyDown(typeof(CedillaReader)))
|
||||
_click.Execute();
|
||||
if (_customInput.KeyDown(typeof(IxReader)))
|
||||
_click.Execute();
|
||||
if (_customInput.KeyDown(typeof(LlReader)))
|
||||
_click.Execute();
|
||||
if (_customInput.KeyDown(typeof(NyReader)))
|
||||
_click.Execute();
|
||||
if (_customInput.KeyDown(typeof(SsReader)))
|
||||
_click.Execute();
|
||||
if (_customInput.KeyDown(typeof(TgReader)))
|
||||
_click.Execute();
|
||||
if (_customInput.KeyDown(typeof(TjReader)))
|
||||
_click.Execute();
|
||||
if (_customInput.KeyDown(typeof(TxReader)))
|
||||
_click.Execute();
|
||||
}
|
||||
|
||||
public void UpdateView(int score) {
|
||||
text.text = score.ToString();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/View/UI/ExpressionInput.cs.meta
Normal file
11
Assets/Scripts/View/UI/ExpressionInput.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7a6ab8726a3100840b7f1ba17e278262
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
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);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/View/UI/UIVisibility.cs.meta
Normal file
11
Assets/Scripts/View/UI/UIVisibility.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 20b23959801b4fd40967d39ed926e9f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/View/UI/UnfocusableEventSystem.cs
Normal file
8
Assets/Scripts/View/UI/UnfocusableEventSystem.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace View.UI {
|
||||
public class UnfocusableEventSystem : EventSystem {
|
||||
//Dummy method to prevent calling base method
|
||||
protected override void OnApplicationFocus(bool hasFocus) { }
|
||||
}
|
||||
}
|
11
Assets/Scripts/View/UI/UnfocusableEventSystem.cs.meta
Normal file
11
Assets/Scripts/View/UI/UnfocusableEventSystem.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f88b65679ed919a4196a1cbeb4a47809
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue