using System; namespace UnityEngine.XR.ARKit { /// /// A default implementation of . /// public class DefaultARKitSessionDelegate : ARKitSessionDelegate { /// /// The number of session reset attempts remaining. /// /// public int retriesRemaining { get; protected set; } /// /// (Read Only) The maximum number of attempts to reset the session if the session fails. /// /// public virtual int maxRetryCount { get; set; } = 5; /// /// Default handling for session failures. This implementation logs an error and attempts to /// [reset](xref:UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Reset) the session up to /// times. /// /// The which provides an interface to the /// ARKit session. /// The object describing the failure. 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."); } } /// /// Resets the to . /// /// The which provides an interface to the /// ARKit session. protected override void OnConfigurationChanged(ARKitSessionSubsystem sessionSubsystem) { retriesRemaining = maxRetryCount; } } }