add DOTween / add start settings
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using Zenject;
|
||||
using UltraFace;
|
||||
using DG.Tweening;
|
||||
|
||||
public class ImageCanvasHandler : MonoBehaviour
|
||||
{
|
||||
[Inject] private Visualizer _visualizer;
|
||||
[SerializeField] private RawImage _rawImage;
|
||||
private RectTransform _rectTransform;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_rectTransform = GetComponent<RectTransform>();
|
||||
_visualizer.OnDetectionStatusChanged += ChangeState;
|
||||
}
|
||||
|
||||
private void ChangeState(bool isActive)
|
||||
{
|
||||
if(isActive)
|
||||
{
|
||||
_rawImage.DOFade(1, .25f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rawImage.DOFade(0, .25f);
|
||||
}
|
||||
|
||||
_rectTransform.DORotate(_rectTransform.eulerAngles + Vector3.up * 360, .5f);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_visualizer.OnDetectionStatusChanged -= ChangeState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fdf61e6e388c35409860bbb41d0804a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Zenject;
|
||||
using UltraFace;
|
||||
using TMPro;
|
||||
|
||||
public class SettingsUI : MonoBehaviour
|
||||
{
|
||||
[Inject] private Visualizer _visualizer;
|
||||
[Inject] private DetectionSetup _detectionSetup;
|
||||
|
||||
[SerializeField] private TMP_Text _faceCounterText;
|
||||
[SerializeField] private TMP_Text _minFaceHeight;
|
||||
[SerializeField] private TMP_Text _maxFaceHeight;
|
||||
[SerializeField] private Button _acceptButton;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_acceptButton.onClick.AddListener(() => OnAcceptButtonClick());
|
||||
}
|
||||
|
||||
private void OnAcceptButtonClick()
|
||||
{
|
||||
_detectionSetup.SetMinFaceHeight(float.Parse(_maxFaceHeight.text));
|
||||
Debug.LogWarning($"минимальная дистанция - {_maxFaceHeight.text}");
|
||||
_visualizer.Init();
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var faceCounter = _visualizer.faceCounter;
|
||||
var minFaceHeight = _visualizer.minFaceHeight;
|
||||
var maxFaceHeight = _visualizer.maxFaceHeight;
|
||||
|
||||
_faceCounterText.text = faceCounter.ToString();
|
||||
_faceCounterText.color = faceCounter != 0 ? Color.green : Color.red;
|
||||
|
||||
_minFaceHeight.text = minFaceHeight.ToString();
|
||||
_maxFaceHeight.text = maxFaceHeight.ToString();
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_acceptButton.onClick.RemoveAllListeners();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9031c3a3c7150049a10dd2075aed468
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user