/// <summary> /// Default handling for session failures. This implementation logs an error and attempts to /// [reset](xref:UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Reset) the session up to /// <see cref="maxRetryCount"/> times. /// </summary> /// <param name="sessionSubsystem">The <see cref="ARKitSessionSubsystem"/> which provides an interface to the /// ARKit session.</param> /// <param name="error">The <see cref="NSError"/> object describing the failure.</param> protected override void OnSessionDidFailWithError(ARKitSessionSubsystem sessionSubsystem, NSError error) { if (retriesRemaining > 0) { --retriesRemaining; Debug.LogWarning($"The session has failed with error code {error.code}: \"{error.localizedDescription}\". Attempting reset ({retriesRemaining} retries remaining)."); sessionSubsystem.Reset(); } else { Debug.LogError($"The session has failed with error code {error.code}: \"{error.localizedDescription}\". Retry limit of {maxRetryCount} has been reached. No further attempts will be made to reset the session unless the configuration changes."); } }
/// <summary> /// Invoked when the /// [coaching experience](https://developer.apple.com/documentation/arkit/arcoachingoverlayview?language=objc) /// is completely deactivated. This base class implementation does nothing. /// </summary> /// <remarks> /// See [coachingOverlayViewDidDeactivate:](https://developer.apple.com/documentation/arkit/arcoachingoverlayviewdelegate/3152983-coachingoverlayviewdiddeactivate?language=objc) /// for more information. /// </remarks> /// <param name="sessionSubsystem">The <see cref="ARKitSessionSubsystem"/> which provides an interface to the ARKit session.</param> /// <seealso cref="ARKitSessionSubsystem.requestedCoachingGoal"/> /// <seealso cref="ARKitSessionSubsystem.currentCoachingGoal"/> /// <seealso cref="ARKitSessionSubsystem.SetCoachingActive"/> /// <seealso cref="OnCoachingOverlayViewWillActivate"/> protected virtual void OnCoachingOverlayViewDidDeactivate(ARKitSessionSubsystem sessionSubsystem) { }
/// <summary> /// Invoked when a change to the /// [ARConfiguration](https://developer.apple.com/documentation/arkit/arconfiguration?language=objc) /// is requested. /// </summary> /// <param name="sessionSubsystem">The <see cref="ARKitSessionSubsystem"/> which provides an interface to the ARKit session.</param> protected virtual void OnConfigurationChanged(ARKitSessionSubsystem sessionSubsystem) { }
/// <summary> /// Invoked when the session fails. This base class implementation does nothing. /// </summary> /// <remarks> /// Use this to respond to session failures. For example, the <see cref="DefaultARKitSessionDelegate"/> /// implementation tries to restart the session by calling /// [Reset](xref:UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Reset). /// /// See [session:didFailWithError:](https://developer.apple.com/documentation/arkit/arsessionobserver/2887453-session?language=objc) /// for more information. /// </remarks> /// <param name="sessionSubsystem">The <see cref="ARKitSessionSubsystem"/> which provides an interface to the ARKit session.</param> /// <param name="error">The <see cref="NSError"/> object describing the failure. This object is only valid /// during this callback. See also <see cref="ARKitErrorCode"/>.</param> protected virtual void OnSessionDidFailWithError(ARKitSessionSubsystem sessionSubsystem, NSError error) { }
/// <summary> /// Resets the <see cref="retriesRemaining"/> to <see cref="maxRetryCount"/>. /// </summary> /// <param name="sessionSubsystem">The <see cref="ARKitSessionSubsystem"/> which provides an interface to the /// ARKit session.</param> protected override void OnConfigurationChanged(ARKitSessionSubsystem sessionSubsystem) { retriesRemaining = maxRetryCount; }