base functional
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using Zenject;
|
||||
using UltraFace;
|
||||
|
||||
public class AnimationHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform[] _objects;
|
||||
[SerializeField] private Transform[] _points;
|
||||
[Inject] private Visualizer _visualizer;
|
||||
|
||||
private Dictionary<string, Vector3> _scales;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_scales = new Dictionary<string, Vector3>();
|
||||
|
||||
_visualizer.OnDetectionStatusChanged += OnFaceDetected;
|
||||
foreach(var item in _objects)
|
||||
{
|
||||
int rotateDir = Random.Range(-4, 5);
|
||||
_scales.Add(item.name, item.localScale);
|
||||
item.DOScale(Vector3.zero, 0);
|
||||
|
||||
item.DOLocalRotate(new Vector3(0, rotateDir > 0 ? 360f : -360f, 0), Random.Range(5f, 10f), RotateMode.FastBeyond360)
|
||||
.SetLoops(-1, LoopType.Restart)
|
||||
.SetRelative()
|
||||
.SetEase(Ease.Linear);
|
||||
|
||||
item.DOLocalMoveY(item.localPosition.y + .5f, Random.Range(.5f, 5f))
|
||||
.SetEase(Ease.InOutSine)
|
||||
.SetLoops(-1, LoopType.Yoyo);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFaceDetected(bool isDetected)
|
||||
{
|
||||
foreach(var item in _objects)
|
||||
item.DOScale(isDetected ? _scales[item.name] : Vector3.zero, Random.Range(.2f, .8f));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9efc327eb0e14ab4d9b2f9c70b144ab4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,12 +9,13 @@ using DG.Tweening;
|
||||
public class ImageCanvasHandler : MonoBehaviour
|
||||
{
|
||||
[Inject] private Visualizer _visualizer;
|
||||
[SerializeField] private RawImage _rawImage;
|
||||
private RectTransform _rectTransform;
|
||||
private CanvasGroup _canvasGroup;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_rectTransform = GetComponent<RectTransform>();
|
||||
_canvasGroup = GetComponent<CanvasGroup>();
|
||||
_visualizer.OnDetectionStatusChanged += ChangeState;
|
||||
}
|
||||
|
||||
@@ -22,11 +23,11 @@ public class ImageCanvasHandler : MonoBehaviour
|
||||
{
|
||||
if(isActive)
|
||||
{
|
||||
_rawImage.DOFade(1, .25f);
|
||||
_canvasGroup.DOFade(1, .25f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rawImage.DOFade(0, .25f);
|
||||
_canvasGroup.DOFade(0, .25f);
|
||||
}
|
||||
|
||||
_rectTransform.DORotate(_rectTransform.eulerAngles + Vector3.up * 360, .5f);
|
||||
|
||||
@@ -39,8 +39,8 @@ public class SettingsUI : MonoBehaviour
|
||||
_faceCounterText.text = faceCounter.ToString();
|
||||
_faceCounterText.color = faceCounter != 0 ? Color.green : Color.red;
|
||||
|
||||
_minFaceHeight.text = minFaceHeight.ToString();
|
||||
_maxFaceHeight.text = maxFaceHeight.ToString();
|
||||
_minFaceHeight.text = minFaceHeight.ToString("0.00");
|
||||
_maxFaceHeight.text = maxFaceHeight.ToString("0.00");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ namespace UltraFace
|
||||
_previewUI.texture = _source.Texture;
|
||||
|
||||
if(!_detectionSetup.isValidate) return;
|
||||
Debug.Log(_detectedCounter.Count);
|
||||
|
||||
_detectedCounter.Add(maxFaceHeight > _detectionSetup.minFaceHeight ? true : false);
|
||||
if(_detectedCounter.Count == 128)
|
||||
@@ -101,6 +100,9 @@ namespace UltraFace
|
||||
OnDetectionStatusChanged?.Invoke(_isDetected);
|
||||
_detectedCounter = new List<bool>();
|
||||
}
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.Space))
|
||||
OnDetectionStatusChanged?.Invoke(!_isDetected);
|
||||
}
|
||||
|
||||
void OnRenderObject()
|
||||
|
||||
Reference in New Issue
Block a user