This repository has been archived on 2020-08-22. You can view files and clone it, but cannot push or open issues or pull requests.
flutter-unity-view-widget/example/unity/ARDemoApp/Assets/Scripts/EyeTrackingUI.cs

32 lines
899 B
C#
Executable File

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Text = UnityEngine.UI.Text;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
[RequireComponent(typeof(Text))]
public class EyeTrackingUI : MonoBehaviour
{
[SerializeField]
ARFaceManager m_Manager;
void OnEnable()
{
if (m_Manager == null)
{
m_Manager = FindObjectOfType<ARFaceManager>();
}
if (m_Manager != null && m_Manager.subsystem != null && m_Manager.subsystem.SubsystemDescriptor.supportsEyeTracking)
{
var infoGO = GetComponent<Text>();
infoGO.text = "This device supports eye tracking.";
}
else
{
var infoGO = GetComponent<Text>();
infoGO.text = "This device does not support eye tracking.";
}
}
}