// %BANNER_BEGIN% // --------------------------------------------------------------------- // %COPYRIGHT_BEGIN% // Copyright (c) 2023 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 System.Runtime.InteropServices; using UnityEngine.XR.MagicLeap.Native; namespace UnityEngine.XR.MagicLeap { public partial class MLSpace : MLAutoAPISingleton { /// /// Start the API. /// Permissions: com.magicleap.permission.SPACE_MANAGER (protection level: normal) /// protected override MLResult.Code StartAPI() => Instance.InternalMLSpacesStart(); /// /// Stop the API. /// protected override MLResult.Code StopAPI() => Instance.InternalMLSpacesStop(); /// /// Export an on device Magic Leap Space. /// Permissions: com.magicleap.permission.SPACE_IMPORT_EXPORT (protection level:dangerous). /// /// Information needed to export the space /// Exported space data /// /// MLResult.Code will be MLResult.Code.Ok if space was exported successfully. /// MLResult.Code will be MLResult.Code.InvalidParam if 1 or more input parameters are not valid. /// MLResult.Code will be MLResult.Code.PermissionDenied if necessary permission is missing. /// MLResult.Code will be MLResult.UnspecifiedFailure if failed for unknown reason. /// MLResult.Code will be MLResult.Code.UnavailableSpace if failed due to unavailable space. /// public static MLResult.Code ExportSpace(in SpaceInfo info, out SpaceData data) => Instance.InternalExportSpace(in info, out data); /// /// Import a Magic Leap Space. /// Permissions: com.magicleap.permission.SPACE_IMPORT_EXPORT (protection level:dangerous). /// /// Information needed to import the space /// Space data returned on successful import /// /// MLResult.Code will be MLResult.Code.Ok if space was imported successfully. /// MLResult.Code will be MLResult.Code.InvalidParam if 1 or more input parameters are not valid. /// MLResult.Code will be MLResult.Code.PermissionDenied if necessary permission is missing. /// MLResult.Code will be MLResult.UnspecifiedFailure if failed for unknown reason. /// MLResult.Code will be MLResult.Code.IncompatibleSpace if operation failed due to incompatible space. /// MLResult.Code will be MLResult.Code.SpaceAlreadyExists if space being imported already exists. /// public static MLResult.Code ImportSpace(in SpaceData data, out SpaceInfo id) => Instance.InternalImportSpace(in data, out id); /// /// Get the list of available spaces. /// The list of spaces returned will depend on the current device mapping mode. /// Only the Spaces associated with the current mapping mode will be returned by /// this call.Device mapping mode can be changed via the system application(s). /// Permissions: None. /// /// List of spaces currently available to the device /// /// MLResult.Code will be MLResult.Code.Ok if the list of spaces was retrieved successfully. /// MLResult.Code will be MLResult.Code.InvalidParam if input parameter is not valid. /// MLResult.Code will be MLResult.Code.Unauthenticated if authentication credentials invalid for this operation. /// MLResult.Code will be MLResult.UnspecifiedFailure if failed for unknown reason. /// MLResult.Code will be MLResult.Code.SpacesServerError if operation failed due to server-side error. /// MLResult.Code will be MLResult.Code.SpacesServiceUnavailable if operation failed due to service not being ready. /// public static MLResult.Code GetSpaceList(out Space[] spaceList) => Instance.InternalGetSpaceList(out spaceList); /// /// Send a request to localize to a given Magic Leap Space. /// This is an asynchronous request. Use GetLocalizationResult to get the results of /// the localization, or add a listener to OnLocalizationEvent. /// Permissions: None. /// /// Information about Space to localize into /// /// MLResult.Code will be MLResult.Code.Ok if the request was submitted successfully. /// MLResult.Code will be MLResult.Code.InvalidParam if input parameter is not valid. /// MLResult.Code will be MLResult.Code.Unauthenticated if authentication credentials invalid for this operation. /// MLResult.Code will be MLResult.UnspecifiedFailure if failed for unknown reason. /// MLResult.Code will be MLResult.Code.SpacesServerError if operation failed due to server-side error. /// MLResult.Code will be MLResult.Code.SpacesServiceUnavailable if operation failed due to service not being ready. /// public static MLResult.Code RequestLocalization(ref SpaceInfo info) => Instance.InternalRequestLocalization(ref info); /// /// Get the localization results. Returns the results of the most recent localization /// request. /// Permissions: None. /// /// Contains the result of the localization request /// /// MLResult.Code will be MLResult.Code.Ok if the result was retrieved successfully. /// MLResult.Code will be MLResult.Code.InvalidParam if input parameter is not valid. /// MLResult.Code will be MLResult.Code.Unauthenticated if authentication credentials invalid for this operation. /// MLResult.Code will be MLResult.UnspecifiedFailure if failed for unknown reason. /// public static MLResult.Code GetLocalizationResult(out LocalizationResult result) => Instance.InternalGetLocalizationResult(out result); public delegate void MLSpaceDelegate(ref SpaceLocalizationResult result, IntPtr data); public delegate void OnLocalizationDelegate(LocalizationResult result); /// /// This callback will be invoked whenever there is an update to the localization status. /// Localization events can occur when the application requests for localization via /// or due to other events outside the /// control of the app such as head tracking failure, localization loss. /// public static event OnLocalizationDelegate OnLocalizationEvent { add => OnLocalizationChanged += value; remove => OnLocalizationChanged -= value; } } }