/// <summary> /// Cleans up unmanaged memory /// </summary> /// <param name="isSafeToAccessManagedObjects">Informs the cleanup process it's safe to clear the initialized MLEye(s).</param> protected override void CleanupAPI(bool isSafeToAccessManagedObjects) { if (isSafeToAccessManagedObjects) { LeftEye = null; RightEye = null; } // Attempt to stop the tracker. MLEyeNativeBindings.SetEyeTrackerActive(false); }
/// <summary> /// Starts the eye object requests, Must be called to start receiving eye tracker data from the underlying system. /// </summary> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to an internal error. /// </returns> protected override MLResult StartAPI() { // Attempt to start the tracker & validate. MLEyeNativeBindings.SetEyeTrackerActive(true); if (!MLEyeNativeBindings.GetEyeTrackerActive()) { MLResult result = MLResult.Create(MLResult.Code.UnspecifiedFailure, "UnityMagicLeap - SetEyeTrackerActive() failed to start the tracker."); MLPluginLog.ErrorFormat("MLEyes.StartAPI failed to initialize native eye tracker. Reason: {0}", result); return(result); } LeftEye = new MLEye(MLEye.EyeType.Left); RightEye = new MLEye(MLEye.EyeType.Right); return(MLResult.Create(MLResult.Code.Ok)); }