// %BANNER_BEGIN% // --------------------------------------------------------------------- // %COPYRIGHT_BEGIN% // Copyright (c) (2024) Magic Leap, Inc. All Rights Reserved. // Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2 // Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein. // %COPYRIGHT_END% // --------------------------------------------------------------------- // %BANNER_END% using System; using UnityEngine; using UnityEngine.XR; using UnityEngine.XR.OpenXR; #if UNITY_EDITOR using UnityEditor; using UnityEditor.XR.OpenXR.Features; #endif namespace MagicLeap.OpenXR.Features.EyeTracker { #if UNITY_EDITOR [OpenXRFeature(UiName = "Magic Leap 2 Eye Tracker", Desc = "Necessary to deploy a Magic Leap 2 compatible application with Eye Tracker events.", Company = "Magic Leap", Version = "1.0.0", Priority = -1, BuildTargetGroups = new[] { BuildTargetGroup.Android, BuildTargetGroup.Standalone }, FeatureId = FeatureId, OpenxrExtensionStrings = "XR_ML_eye_tracker" )] #endif public partial class MagicLeapEyeTrackerFeature : MagicLeapOpenXRFeatureBase { public const string FeatureId = "com.magicleap.openxr.feature.ml2_eyetracker"; public const string ExtensionName = "XR_ML_eye_tracker"; [Obsolete("DeviceLocalizedName is no longer applicable since MagicLeapEyeTrackerFeature is no longer an interaction profile. Therefore it is no longer an InputDevice and Eye Tracking Data must be received through MagicLeapEyeTrackerFeature.GetEyeTrackerData().")] public const string DeviceLocalizedName = "Magic Leap Eye Tracker OpenXR"; private EyeTrackerNativeFunctions nativeFunctions; protected override bool UsesExperimentalExtensions => true; protected override bool OnInstanceCreate(ulong xrInstance) { if (OpenXRRuntime.IsExtensionEnabled(ExtensionName)) { var result = base.OnInstanceCreate(xrInstance); if (result) { nativeFunctions = CreateNativeFunctions(); } return result; } Debug.LogError($"{ExtensionName} is not enabled. Disabling {nameof(MagicLeapEyeTrackerFeature)}"); return false; } } [Obsolete("EyeTrackerUsages is no longer applicable since MagicLeapEyeTrackerFeature is no longer an interaction profile. Therefore it is no longer an InputDevice and Eye Tracking Data must be received through MagicLeapEyeTrackerFeature.GetEyeTrackerData().")] public static class EyeTrackerUsages { public static InputFeatureUsage gazePosition = new InputFeatureUsage("gazePosition"); public static InputFeatureUsage gazeRotation = new InputFeatureUsage("gazeRotation"); public static InputFeatureUsage leftPosition = new InputFeatureUsage("leftPosition"); public static InputFeatureUsage leftRotation = new InputFeatureUsage("leftRotation"); public static InputFeatureUsage rightPosition = new InputFeatureUsage("rightPosition"); public static InputFeatureUsage rightRotation = new InputFeatureUsage("rightRotation"); public static InputFeatureUsage vergencePosition = new InputFeatureUsage("vergencePosition"); public static InputFeatureUsage vergenceRotation = new InputFeatureUsage("vergenceRotation"); } }