kinect/codes/Azure-Kinect-Samples/body-tracking-samples/sample_unity_bodytracking/Assets/Scripts/main.cs

39 lines
1.0 KiB
C#

using UnityEngine;
public class main : MonoBehaviour
{
// Handler for SkeletalTracking thread.
public GameObject m_tracker;
private SkeletalTrackingProvider m_skeletalTrackingProvider;
public BackgroundData m_lastFrameData = new BackgroundData();
void Start()
{
//tracker ids needed for when there are two trackers
const int TRACKER_ID = 0;
m_skeletalTrackingProvider = new SkeletalTrackingProvider(TRACKER_ID);
}
void Update()
{
if (m_skeletalTrackingProvider.IsRunning)
{
if (m_skeletalTrackingProvider.GetCurrentFrameData(ref m_lastFrameData))
{
if (m_lastFrameData.NumOfBodies != 0)
{
m_tracker.GetComponent<TrackerHandler>().updateTracker(m_lastFrameData);
}
}
}
}
void OnApplicationQuit()
{
if (m_skeletalTrackingProvider != null)
{
m_skeletalTrackingProvider.Dispose();
}
}
}