You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
57 lines
1.5 KiB
|
1 month ago
|
using NaughtyAttributes;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using TMPro;
|
||
|
|
using UnityEngine;
|
||
|
|
using static UDE_HAND_INTERACTION.HandStaticPose;
|
||
|
|
|
||
|
|
namespace UDE_HAND_INTERACTION
|
||
|
|
{
|
||
|
|
public class StaticPoseDetector : MonoBehaviour
|
||
|
|
{
|
||
|
|
public Material DefaultGrid;
|
||
|
|
|
||
|
|
public HandStaticPose[] handStaticPoses;
|
||
|
|
|
||
|
|
public List<HandStaticPose> LeftPoses { get; private set; } = new();
|
||
|
|
public List<HandStaticPose> RightPoses { get; private set; } = new();
|
||
|
|
|
||
|
|
public TextMeshPro PoseMsg;
|
||
|
|
[Button]
|
||
|
|
public void DetectPoses()
|
||
|
|
{
|
||
|
|
handStaticPoses = GetComponentsInChildren<HandStaticPose>();
|
||
|
|
}
|
||
|
|
// Start is called before the first frame update
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
DetectPoses();
|
||
|
|
foreach (HandStaticPose pose in handStaticPoses)
|
||
|
|
{
|
||
|
|
if(pose.handness == Handness.Left)
|
||
|
|
{
|
||
|
|
LeftPoses.Add(pose);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
RightPoses.Add(pose);
|
||
|
|
}
|
||
|
|
pose.OnPoseDetectResult += PoseDetectAnnouncement;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void PoseDetectAnnouncement(object sender, StaticPoseDetectEventArgs e)
|
||
|
|
{
|
||
|
|
if(e.IsDetected)
|
||
|
|
{
|
||
|
|
Debug.Log($"{e._Pose.name} is detected.");
|
||
|
|
PoseMsg.text = $"{e._Pose.name} is detected.";
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
PoseMsg.text = "No Pose.";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|