From a04dcbf370525b1158e9ff1bcafddd080e4bc33a Mon Sep 17 00:00:00 2001 From: Ben Sawyer Date: Wed, 20 Mar 2024 14:04:39 -0400 Subject: [PATCH] Release v2.1.0 --- CHANGELOG.md | 31 + Editor/APKBuilder.cs | 51 - Editor/MLAppSim/AppSimShimLibSupport.cs | 114 - Editor/MLAppSim/LabDriverControl.cs | 431 - Editor/MagicLeapSDKUtil.cs | 21 +- Editor/OpenXR/MagicLeapFeatureGroup.cs | 66 +- ...gicLeapRenderingExtensionsFeatureEditor.cs | 55 + ...pRenderingExtensionsFeatureEditor.cs.meta} | 2 +- .../Permissions/PermissionSettingsLoader.cs | 7 +- .../Permissions/data~/ml_permissions.json | 93 + .../Preferences/MagicLeapEditorPreferences.cs | 471 - .../MagicLeapEditorPreferences.uxml | 16 - .../MagicLeapEditorPreferences.uxml.meta | 10 - .../Preferences/SettingsProviderStyle.uss | 33 - .../SettingsProviderStyle.uss.meta | 11 - Plugins/Android/libMLAudioOutput.so | Bin 172968 -> 172968 bytes Plugins/Android/libMagicLeapXrProvider.so | Bin 6434824 -> 8139968 bytes .../Android/libMagicLeapXrProvider.so.meta | 7 - Plugins/Android/libml_c_utils.so.meta | 7 - Plugins/Android/libml_sdk_loader.so | Bin 6188464 -> 6188424 bytes Plugins/Android/libml_sdk_loader.so.meta | 7 - Plugins/Android/libml_systrace_plugin.so.meta | 7 - .../libml_unity_native_logging.so.meta | 7 - Plugins/Android/libml_ycbcr_renderer.so.meta | 7 - Plugins/MacEditor/libMLAudioOutput.dylib | Bin 119640 -> 119912 bytes .../MacEditor/libMagicLeapXrProvider.dylib | Bin 758688 -> 943648 bytes .../libMagicLeapXrProvider.dylib.meta | 7 - Plugins/MacEditor/libml_sdk_loader.dylib | Bin 3203480 -> 4185384 bytes Plugins/MacEditor/libml_sdk_loader.dylib.meta | 7 - .../MacEditor/libml_sdk_tests_provider.dylib | Bin 80088 -> 80107 bytes .../libml_unity_native_logging.dylib | Bin 122200 -> 124445 bytes .../libml_unity_native_logging.dylib.meta | 7 - Plugins/WindowsEditor/MLAudioOutput.dll | Bin 18944 -> 18944 bytes Plugins/WindowsEditor/MagicLeapXrProvider.dll | Bin 198144 -> 304128 bytes Plugins/WindowsEditor/ml_sdk_loader.dll | Bin 403456 -> 403456 bytes Plugins/WindowsEditor/ml_sdk_loader.dll.meta | 7 - .../WindowsEditor/ml_sdk_tests_provider.dll | Bin 17920 -> 17920 bytes .../WindowsEditor/ml_unity_native_logging.dll | Bin 24576 -> 24576 bytes .../ml_unity_native_logging.dll.meta | 7 - .../APIs/AndroidCamera.meta | 2 +- Runtime/APIs/AndroidCamera/AndroidCamera.cs | 304 + .../APIs/AndroidCamera/AndroidCamera.cs.meta | 3 + .../AndroidCamera/AndroidCameraManager.cs | 255 + .../AndroidCameraManager.cs.meta | 3 + .../AndroidCameraMetadataTags.cs | 10860 ++++++++++++++++ .../AndroidCameraMetadataTags.cs.meta | 3 + .../AndroidCameraPlayerLoopUtility.cs | 92 + .../AndroidCameraPlayerLoopUtility.cs.meta | 3 + Runtime/APIs/AndroidCamera/CaptureRequest.cs | 91 + .../APIs/AndroidCamera/CaptureRequest.cs.meta | 3 + Runtime/APIs/AndroidCamera/JPEGUtility.cs | 14 + .../APIs/AndroidCamera/JPEGUtility.cs.meta | 3 + Runtime/APIs/AndroidCamera/NDK.meta | 3 + .../NDK/ACameraCaptureFailure.cs | 60 + .../NDK/ACameraCaptureFailure.cs.meta | 3 + .../NDK/ACameraCaptureSession.cs | 211 + .../NDK/ACameraCaptureSession.cs.meta | 3 + .../APIs/AndroidCamera/NDK/ACameraDevice.cs | 145 + .../AndroidCamera/NDK/ACameraDevice.cs.meta | 3 + .../APIs/AndroidCamera/NDK/ACameraIdList.cs | 67 + .../AndroidCamera/NDK/ACameraIdList.cs.meta | 3 + .../APIs/AndroidCamera/NDK/ACameraManager.cs | 185 + .../AndroidCamera/NDK/ACameraManager.cs.meta | 3 + .../APIs/AndroidCamera/NDK/ACameraMetadata.cs | 135 + .../AndroidCamera/NDK/ACameraMetadata.cs.meta | 3 + .../AndroidCamera/NDK/ACameraOutputTarget.cs | 41 + .../NDK/ACameraOutputTarget.cs.meta | 3 + .../APIs/AndroidCamera/NDK/ACaptureRequest.cs | 248 + .../AndroidCamera/NDK/ACaptureRequest.cs.meta | 3 + .../NDK/ACaptureSessionOutput.cs | 29 + .../NDK/ACaptureSessionOutput.cs.meta | 3 + .../NDK/ACaptureSessionOutputContainer.cs | 56 + .../ACaptureSessionOutputContainer.cs.meta | 3 + .../APIs/AndroidCamera/NDK/AHardwareBuffer.cs | 660 + .../AndroidCamera/NDK/AHardwareBuffer.cs.meta | 3 + Runtime/APIs/AndroidCamera/NDK/AImage.cs | 140 + Runtime/APIs/AndroidCamera/NDK/AImage.cs.meta | 3 + .../APIs/AndroidCamera/NDK/AImageReader.cs | 135 + .../AndroidCamera/NDK/AImageReader.cs.meta | 3 + .../APIs/AndroidCamera/NDK/ANativeWindow.cs | 23 + .../AndroidCamera/NDK/ANativeWindow.cs.meta | 3 + .../APIs/AndroidCamera/NDK/CameraConstants.cs | 15 +- .../AndroidCamera/NDK/CameraConstants.cs.meta | 3 + .../AndroidCamera/NDK/CameraNativeBindings.cs | 190 + .../NDK/CameraNativeBindings.cs.meta | 3 + .../APIs/AndroidCamera/NDK/CameraStatus.cs | 91 + .../AndroidCamera/NDK/CameraStatus.cs.meta | 3 + .../AndroidCamera/NDK/INullablePointer.cs | 35 + .../NDK/INullablePointer.cs.meta | 3 + .../APIs/AndroidCamera/NDK/MediaConstants.cs | 10 + .../AndroidCamera/NDK/MediaConstants.cs.meta | 3 + Runtime/APIs/AndroidCamera/NDK/MediaFormat.cs | 565 + .../AndroidCamera/NDK/MediaFormat.cs.meta | 3 + .../AndroidCamera/NDK/MediaNativeBindings.cs | 78 + .../NDK/MediaNativeBindings.cs.meta | 3 + Runtime/APIs/AndroidCamera/NDK/MediaStatus.cs | 116 + .../AndroidCamera/NDK/MediaStatus.cs.meta | 3 + .../NDK/NativeWindowNativeBindings.cs | 54 + .../NDK/NativeWindowNativeBindings.cs.meta | 3 + Runtime/APIs/AndroidCamera/NativeImage.cs | 551 + .../APIs/AndroidCamera/NativeImage.cs.meta | 3 + Runtime/APIs/AndroidCamera/RequestTemplate.cs | 28 + .../AndroidCamera/RequestTemplate.cs.meta | 3 + Runtime/APIs/AndroidCamera/SequenceId.cs | 41 + Runtime/APIs/AndroidCamera/SequenceId.cs.meta | 3 + .../APIs/AndroidCamera/StreamConfiguration.cs | 139 + .../AndroidCamera/StreamConfiguration.cs.meta | 3 + Runtime/APIs/AndroidCamera/UnsafeImage.cs | 292 + .../APIs/AndroidCamera/UnsafeImage.cs.meta | 3 + Runtime/APIs/AndroidCamera/YUVUtility.cs | 93 + Runtime/APIs/AndroidCamera/YUVUtility.cs.meta | 3 + Runtime/APIs/CVCamera/MLCVCamera.cs | 13 +- .../APIs/{Permissions.meta => MLInput.meta} | 2 +- .../MLInput/MLInput.inputactions} | 4 +- .../MLInput/MLInput.inputactions.meta} | 0 .../MLInput}/MagicLeapInputs.cs | 567 +- .../MLInput}/MagicLeapInputs.cs.meta | 0 .../MLMarkerTrackerNativeBindings.cs | 2 +- .../MLPermissionsNativeBindings.cs | 79 - .../MLPermissionsNativeBindings.cs.meta | 11 - Runtime/Common/NativeRingBuffer.cs | 1084 ++ Runtime/Common/NativeRingBuffer.cs.meta | 3 + .../Utils}/MLPermissionNames.cs | 0 .../Utils}/MLPermissionNames.cs.meta | 0 Runtime/Common/Utils/MLPermissions.cs | 40 + .../Common/Utils/MLPermissions.cs.meta | 2 +- Runtime/Common/Utils/MLPluginLog.cs | 33 + Runtime/Common/Utils/PlayerLoopUtil.cs | 41 + .../Common/Utils/PlayerLoopUtil.cs.meta | 2 +- Runtime/Common/Utils/UnsafeUtilityEx.cs | 86 +- .../Bindings/MLCameraBaseNativeStructs.cs | 21 +- .../MLPermissions.cs | 58 +- .../MLPermissions.cs.meta | 0 .../MediaPlayer/API/MLMediaPlayerEditor.cs | 403 - .../API/MLMediaPlayerEditor.cs.meta | 11 - Runtime/Deprecated/WebRTC/Shaders/Native.mat | 9 +- Runtime/Deprecated/WebRTC/Shaders/RGB.mat | 24 +- Runtime/MagicLeap.SDK.asmdef | 4 +- .../OpenXR/FacialExpression.meta | 2 +- .../MagicLeapFacialExpression.cs | 36 + .../MagicLeapFacialExpression.cs.meta | 2 +- .../MagicLeapFacialExpressionData.cs | 95 + .../MagicLeapFacialExpressionData.cs.meta | 11 + .../MagicLeapFacialExpressionFeature.cs | 51 + .../MagicLeapFacialExpressionFeature.cs.meta | 11 + ...MagicLeapFacialExpressionNativeBindings.cs | 38 + ...LeapFacialExpressionNativeBindings.cs.meta | 11 + Runtime/OpenXR/LocalizationMap.meta | 8 + .../MagicLeapLocalizationMapFeature.cs | 227 + .../MagicLeapLocalizationMapFeature.cs.meta | 11 + ...eapLocalizationMapFeatureNativeBindings.cs | 148 + ...calizationMapFeatureNativeBindings.cs.meta | 11 + Runtime/OpenXR/MLCompat.meta | 8 + Runtime/OpenXR/MLCompat/MLEyeTracking.cs | 62 + Runtime/OpenXR/MLCompat/MLEyeTracking.cs.meta | 11 + Runtime/OpenXR/MLCompat/MLHeadTracking.cs | 95 + .../OpenXR/MLCompat/MLHeadTracking.cs.meta | 11 + Runtime/OpenXR/MLCompat/MLInput.cs | 204 + Runtime/OpenXR/MLCompat/MLInput.cs.meta | 11 + Runtime/OpenXR/MagicLeapFeature.cs | 79 +- .../OpenXR/MagicLeapFeatureNativeBindings.cs | 23 +- Runtime/OpenXR/MagicLeapOpenXRFeatureBase.cs | 75 +- Runtime/OpenXR/MagicLeapProjectValidation.cs | 301 + .../OpenXR/MagicLeapProjectValidation.cs.meta | 11 + .../MagicLeapRenderingExtensionsFeature.cs | 2 +- Runtime/OpenXR/MarkerUnderstanding.meta | 8 + .../MagicLeapMarkerUnderstanding.cs | 103 + .../MagicLeapMarkerUnderstanding.cs.meta | 11 + .../MagicLeapMarkerUnderstandingData.cs | 498 + .../MagicLeapMarkerUnderstandingData.cs.meta | 11 + .../MagicLeapMarkerUnderstandingFeature.cs | 56 + ...agicLeapMarkerUnderstandingFeature.cs.meta | 11 + ...icLeapMarkerUnderstandingMarkerDetector.cs | 213 + ...pMarkerUnderstandingMarkerDetector.cs.meta | 11 + ...icLeapMarkerUnderstandingNativeBindings.cs | 59 + ...pMarkerUnderstandingNativeBindings.cs.meta | 11 + Runtime/OpenXR/Meshing.meta | 3 + .../OpenXR/Meshing/MagicLeapMeshingFeature.cs | 241 + .../Meshing/MagicLeapMeshingFeature.cs.meta | 3 + .../MagicLeapXrMeshingNativeBindings.cs | 47 + .../MagicLeapXrMeshingNativeBindings.cs.meta | 3 + .../OpenXR/Meshing/MagicLeapXrMeshingTypes.cs | 83 + .../Meshing/MagicLeapXrMeshingTypes.cs.meta | 3 + Runtime/OpenXR/Meshing/PointCloud.meta | 3 + ...MagicLeapOpenXRPointCloudNativeBindings.cs | 22 + ...LeapOpenXRPointCloudNativeBindings.cs.meta | 11 + .../MagicLeapOpenXRPointCloudSubsystem.cs | 148 + ...MagicLeapOpenXRPointCloudSubsystem.cs.meta | 3 + Runtime/OpenXR/NativeInteropTypes.cs | 9 +- Runtime/OpenXR/OpenXRUtils.cs | 105 +- .../OpenXR/Planes/MagicLeapPlanesFeature.cs | 4 +- Runtime/OpenXR/Planes/Subsystem.meta | 8 + .../Planes/Subsystem/ConvexHullGenerator.cs | 190 + .../Subsystem/ConvexHullGenerator.cs.meta | 11 + .../Planes/Subsystem/CopyPlaneResultsJob.cs | 75 + .../Subsystem/CopyPlaneResultsJob.cs.meta | 11 + .../Planes/Subsystem/MLPlanesQueryFlags.cs | 152 + .../Subsystem/MLPlanesQueryFlags.cs.meta | 11 + .../Planes/Subsystem/MLXrPlaneSubsystem.cs | 474 + .../Subsystem/MLXrPlaneSubsystem.cs.meta | 11 + .../MagicLeapXrPlanesNativeBindings.cs | 34 + .../MagicLeapXrPlanesNativeBindings.cs.meta | 3 + .../OpenXR/Planes/Subsystem/PlaneBoundary.cs | 181 + .../Planes/Subsystem/PlaneBoundary.cs.meta | 11 + Runtime/OpenXR/Planes/Subsystem/XRTypes.cs | 85 + .../OpenXR/Planes/Subsystem/XRTypes.cs.meta | 3 + Runtime/OpenXR/SpatialAnchors.meta | 8 + .../MagicLeapSpatialAnchorsFeature.cs | 89 + .../MagicLeapSpatialAnchorsFeature.cs.meta | 11 + ...LeapSpatialAnchorsFeatureNativeBindings.cs | 46 + ...patialAnchorsFeatureNativeBindings.cs.meta | 11 + .../MagicLeapSpatialAnchorsStorageFeature.cs | 537 + ...icLeapSpatialAnchorsStorageFeature.cs.meta | 11 + ...tialAnchorsStorageFeatureNativeBindings.cs | 79 + ...nchorsStorageFeatureNativeBindings.cs.meta | 11 + Runtime/OpenXR/SpatialAnchors/Subsystem.meta | 8 + .../Subsystem/MLXrAnchorSubsystem.cs | 355 + .../Subsystem/MLXrAnchorSubsystem.cs.meta | 11 + Runtime/OpenXR/SystemNotifications.meta | 8 + .../MagicLeapSystemNotificationsFeature.cs | 67 + ...agicLeapSystemNotificationsFeature.cs.meta | 11 + ...ystemNotificationsFeatureNativeBindings.cs | 34 + ...NotificationsFeatureNativeBindings.cs.meta | 11 + .../MagicLeapUserCalibrationFeature.cs | 3 +- Runtime/Subsystems/Anchors/AnchorSubsystem.cs | 2 + .../Input/Extensions/MLHeadTracking.cs | 33 +- .../Meshing/MeshingSubsystemComponent.cs | 2 +- .../Meshing/MeshingSubsystemLifecycle.cs | 8 +- Runtime/Subsystems/Planes/PlanesSubsystem.cs | 4 +- .../Materials/Controller/Controller.png.meta | 12 - Runtime/Tools/Prefabs/XR Rig.prefab | 2 +- Runtime/XrProvider/MagicLeapXrProvider.cs | 1 + Samples~/Rig&Inputs.meta | 8 + .../ML Rig.prefab | 178 +- .../ML Rig.prefab.meta | 0 .../MagicLeapOpenXRInput.inputactions} | 616 + .../MagicLeapOpenXRInput.inputactions.meta} | 0 .../MLWorldCameraExistingStructSizeTests.cs | 2 +- ...LWorldCameraNativeBindingsEditModeTests.cs | 2 +- Tests/Runtime/Common/NativeRingBufferTests.cs | 168 + .../Common/NativeRingBufferTests.cs.meta | 3 + package.json | 15 +- 242 files changed, 24758 insertions(+), 2251 deletions(-) delete mode 100644 Editor/MLAppSim/AppSimShimLibSupport.cs delete mode 100644 Editor/MLAppSim/LabDriverControl.cs create mode 100644 Editor/OpenXR/MagicLeapRenderingExtensionsFeatureEditor.cs rename Editor/{SettingsProviders/Preferences/MagicLeapEditorPreferences.cs.meta => OpenXR/MagicLeapRenderingExtensionsFeatureEditor.cs.meta} (83%) create mode 100644 Editor/SettingsProviders/Permissions/data~/ml_permissions.json delete mode 100644 Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.cs delete mode 100644 Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.uxml delete mode 100644 Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.uxml.meta delete mode 100644 Editor/SettingsProviders/Preferences/SettingsProviderStyle.uss delete mode 100644 Editor/SettingsProviders/Preferences/SettingsProviderStyle.uss.meta rename Editor/MLAppSim.meta => Runtime/APIs/AndroidCamera.meta (77%) create mode 100644 Runtime/APIs/AndroidCamera/AndroidCamera.cs create mode 100644 Runtime/APIs/AndroidCamera/AndroidCamera.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/AndroidCameraManager.cs create mode 100644 Runtime/APIs/AndroidCamera/AndroidCameraManager.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/AndroidCameraMetadataTags.cs create mode 100644 Runtime/APIs/AndroidCamera/AndroidCameraMetadataTags.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/AndroidCameraPlayerLoopUtility.cs create mode 100644 Runtime/APIs/AndroidCamera/AndroidCameraPlayerLoopUtility.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/CaptureRequest.cs create mode 100644 Runtime/APIs/AndroidCamera/CaptureRequest.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/JPEGUtility.cs create mode 100644 Runtime/APIs/AndroidCamera/JPEGUtility.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraCaptureFailure.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraCaptureFailure.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraCaptureSession.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraCaptureSession.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraDevice.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraDevice.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraIdList.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraIdList.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraManager.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraManager.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraMetadata.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraMetadata.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraOutputTarget.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACameraOutputTarget.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACaptureRequest.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACaptureRequest.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACaptureSessionOutput.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACaptureSessionOutput.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACaptureSessionOutputContainer.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ACaptureSessionOutputContainer.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/AHardwareBuffer.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/AHardwareBuffer.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/AImage.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/AImage.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/AImageReader.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/AImageReader.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/ANativeWindow.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/ANativeWindow.cs.meta rename Editor/SettingsProviders/Preferences/MagicLeapEditorPreferencesProvider.cs => Runtime/APIs/AndroidCamera/NDK/CameraConstants.cs (62%) create mode 100644 Runtime/APIs/AndroidCamera/NDK/CameraConstants.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/CameraNativeBindings.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/CameraNativeBindings.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/CameraStatus.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/CameraStatus.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/INullablePointer.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/INullablePointer.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/MediaConstants.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/MediaConstants.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/MediaFormat.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/MediaFormat.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/MediaNativeBindings.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/MediaNativeBindings.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/MediaStatus.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/MediaStatus.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NDK/NativeWindowNativeBindings.cs create mode 100644 Runtime/APIs/AndroidCamera/NDK/NativeWindowNativeBindings.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/NativeImage.cs create mode 100644 Runtime/APIs/AndroidCamera/NativeImage.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/RequestTemplate.cs create mode 100644 Runtime/APIs/AndroidCamera/RequestTemplate.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/SequenceId.cs create mode 100644 Runtime/APIs/AndroidCamera/SequenceId.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/StreamConfiguration.cs create mode 100644 Runtime/APIs/AndroidCamera/StreamConfiguration.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/UnsafeImage.cs create mode 100644 Runtime/APIs/AndroidCamera/UnsafeImage.cs.meta create mode 100644 Runtime/APIs/AndroidCamera/YUVUtility.cs create mode 100644 Runtime/APIs/AndroidCamera/YUVUtility.cs.meta rename Runtime/APIs/{Permissions.meta => MLInput.meta} (77%) rename Runtime/{Deprecated/MagicLeapInputs.inputactions => APIs/MLInput/MLInput.inputactions} (99%) rename Runtime/{Deprecated/MagicLeapInputs.inputactions.meta => APIs/MLInput/MLInput.inputactions.meta} (100%) rename Runtime/{Deprecated => APIs/MLInput}/MagicLeapInputs.cs (72%) rename Runtime/{Deprecated => APIs/MLInput}/MagicLeapInputs.cs.meta (100%) delete mode 100644 Runtime/APIs/Permissions/MLPermissionsNativeBindings.cs delete mode 100644 Runtime/APIs/Permissions/MLPermissionsNativeBindings.cs.meta create mode 100644 Runtime/Common/NativeRingBuffer.cs create mode 100644 Runtime/Common/NativeRingBuffer.cs.meta rename Runtime/{APIs/Permissions => Common/Utils}/MLPermissionNames.cs (100%) rename Runtime/{APIs/Permissions => Common/Utils}/MLPermissionNames.cs.meta (100%) create mode 100644 Runtime/Common/Utils/MLPermissions.cs rename Editor/MLAppSim/LabDriverControl.cs.meta => Runtime/Common/Utils/MLPermissions.cs.meta (83%) create mode 100644 Runtime/Common/Utils/PlayerLoopUtil.cs rename Editor/MLAppSim/AppSimShimLibSupport.cs.meta => Runtime/Common/Utils/PlayerLoopUtil.cs.meta (83%) rename Runtime/{APIs/Permissions => Deprecated}/MLPermissions.cs (82%) rename Runtime/{APIs/Permissions => Deprecated}/MLPermissions.cs.meta (100%) delete mode 100644 Runtime/Deprecated/MediaPlayer/API/MLMediaPlayerEditor.cs delete mode 100644 Runtime/Deprecated/MediaPlayer/API/MLMediaPlayerEditor.cs.meta rename Editor/SettingsProviders/Preferences.meta => Runtime/OpenXR/FacialExpression.meta (77%) create mode 100644 Runtime/OpenXR/FacialExpression/MagicLeapFacialExpression.cs rename Editor/SettingsProviders/Preferences/MagicLeapEditorPreferencesProvider.cs.meta => Runtime/OpenXR/FacialExpression/MagicLeapFacialExpression.cs.meta (83%) create mode 100644 Runtime/OpenXR/FacialExpression/MagicLeapFacialExpressionData.cs create mode 100644 Runtime/OpenXR/FacialExpression/MagicLeapFacialExpressionData.cs.meta create mode 100644 Runtime/OpenXR/FacialExpression/MagicLeapFacialExpressionFeature.cs create mode 100644 Runtime/OpenXR/FacialExpression/MagicLeapFacialExpressionFeature.cs.meta create mode 100644 Runtime/OpenXR/FacialExpression/MagicLeapFacialExpressionNativeBindings.cs create mode 100644 Runtime/OpenXR/FacialExpression/MagicLeapFacialExpressionNativeBindings.cs.meta create mode 100644 Runtime/OpenXR/LocalizationMap.meta create mode 100644 Runtime/OpenXR/LocalizationMap/MagicLeapLocalizationMapFeature.cs create mode 100644 Runtime/OpenXR/LocalizationMap/MagicLeapLocalizationMapFeature.cs.meta create mode 100644 Runtime/OpenXR/LocalizationMap/MagicLeapLocalizationMapFeatureNativeBindings.cs create mode 100644 Runtime/OpenXR/LocalizationMap/MagicLeapLocalizationMapFeatureNativeBindings.cs.meta create mode 100644 Runtime/OpenXR/MLCompat.meta create mode 100644 Runtime/OpenXR/MLCompat/MLEyeTracking.cs create mode 100644 Runtime/OpenXR/MLCompat/MLEyeTracking.cs.meta create mode 100644 Runtime/OpenXR/MLCompat/MLHeadTracking.cs create mode 100644 Runtime/OpenXR/MLCompat/MLHeadTracking.cs.meta create mode 100644 Runtime/OpenXR/MLCompat/MLInput.cs create mode 100644 Runtime/OpenXR/MLCompat/MLInput.cs.meta create mode 100644 Runtime/OpenXR/MagicLeapProjectValidation.cs create mode 100644 Runtime/OpenXR/MagicLeapProjectValidation.cs.meta create mode 100644 Runtime/OpenXR/MarkerUnderstanding.meta create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstanding.cs create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstanding.cs.meta create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstandingData.cs create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstandingData.cs.meta create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstandingFeature.cs create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstandingFeature.cs.meta create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstandingMarkerDetector.cs create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstandingMarkerDetector.cs.meta create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstandingNativeBindings.cs create mode 100644 Runtime/OpenXR/MarkerUnderstanding/MagicLeapMarkerUnderstandingNativeBindings.cs.meta create mode 100644 Runtime/OpenXR/Meshing.meta create mode 100644 Runtime/OpenXR/Meshing/MagicLeapMeshingFeature.cs create mode 100644 Runtime/OpenXR/Meshing/MagicLeapMeshingFeature.cs.meta create mode 100644 Runtime/OpenXR/Meshing/MagicLeapXrMeshingNativeBindings.cs create mode 100644 Runtime/OpenXR/Meshing/MagicLeapXrMeshingNativeBindings.cs.meta create mode 100644 Runtime/OpenXR/Meshing/MagicLeapXrMeshingTypes.cs create mode 100644 Runtime/OpenXR/Meshing/MagicLeapXrMeshingTypes.cs.meta create mode 100644 Runtime/OpenXR/Meshing/PointCloud.meta create mode 100644 Runtime/OpenXR/Meshing/PointCloud/MagicLeapOpenXRPointCloudNativeBindings.cs create mode 100644 Runtime/OpenXR/Meshing/PointCloud/MagicLeapOpenXRPointCloudNativeBindings.cs.meta create mode 100644 Runtime/OpenXR/Meshing/PointCloud/MagicLeapOpenXRPointCloudSubsystem.cs create mode 100644 Runtime/OpenXR/Meshing/PointCloud/MagicLeapOpenXRPointCloudSubsystem.cs.meta create mode 100644 Runtime/OpenXR/Planes/Subsystem.meta create mode 100644 Runtime/OpenXR/Planes/Subsystem/ConvexHullGenerator.cs create mode 100644 Runtime/OpenXR/Planes/Subsystem/ConvexHullGenerator.cs.meta create mode 100644 Runtime/OpenXR/Planes/Subsystem/CopyPlaneResultsJob.cs create mode 100644 Runtime/OpenXR/Planes/Subsystem/CopyPlaneResultsJob.cs.meta create mode 100644 Runtime/OpenXR/Planes/Subsystem/MLPlanesQueryFlags.cs create mode 100644 Runtime/OpenXR/Planes/Subsystem/MLPlanesQueryFlags.cs.meta create mode 100644 Runtime/OpenXR/Planes/Subsystem/MLXrPlaneSubsystem.cs create mode 100644 Runtime/OpenXR/Planes/Subsystem/MLXrPlaneSubsystem.cs.meta create mode 100644 Runtime/OpenXR/Planes/Subsystem/MagicLeapXrPlanesNativeBindings.cs create mode 100644 Runtime/OpenXR/Planes/Subsystem/MagicLeapXrPlanesNativeBindings.cs.meta create mode 100644 Runtime/OpenXR/Planes/Subsystem/PlaneBoundary.cs create mode 100644 Runtime/OpenXR/Planes/Subsystem/PlaneBoundary.cs.meta create mode 100644 Runtime/OpenXR/Planes/Subsystem/XRTypes.cs create mode 100644 Runtime/OpenXR/Planes/Subsystem/XRTypes.cs.meta create mode 100644 Runtime/OpenXR/SpatialAnchors.meta create mode 100644 Runtime/OpenXR/SpatialAnchors/MagicLeapSpatialAnchorsFeature.cs create mode 100644 Runtime/OpenXR/SpatialAnchors/MagicLeapSpatialAnchorsFeature.cs.meta create mode 100644 Runtime/OpenXR/SpatialAnchors/MagicLeapSpatialAnchorsFeatureNativeBindings.cs create mode 100644 Runtime/OpenXR/SpatialAnchors/MagicLeapSpatialAnchorsFeatureNativeBindings.cs.meta create mode 100644 Runtime/OpenXR/SpatialAnchors/MagicLeapSpatialAnchorsStorageFeature.cs create mode 100644 Runtime/OpenXR/SpatialAnchors/MagicLeapSpatialAnchorsStorageFeature.cs.meta create mode 100644 Runtime/OpenXR/SpatialAnchors/MagicLeapSpatialAnchorsStorageFeatureNativeBindings.cs create mode 100644 Runtime/OpenXR/SpatialAnchors/MagicLeapSpatialAnchorsStorageFeatureNativeBindings.cs.meta create mode 100644 Runtime/OpenXR/SpatialAnchors/Subsystem.meta create mode 100644 Runtime/OpenXR/SpatialAnchors/Subsystem/MLXrAnchorSubsystem.cs create mode 100644 Runtime/OpenXR/SpatialAnchors/Subsystem/MLXrAnchorSubsystem.cs.meta create mode 100644 Runtime/OpenXR/SystemNotifications.meta create mode 100644 Runtime/OpenXR/SystemNotifications/MagicLeapSystemNotificationsFeature.cs create mode 100644 Runtime/OpenXR/SystemNotifications/MagicLeapSystemNotificationsFeature.cs.meta create mode 100644 Runtime/OpenXR/SystemNotifications/SystemNotificationsFeatureNativeBindings.cs create mode 100644 Runtime/OpenXR/SystemNotifications/SystemNotificationsFeatureNativeBindings.cs.meta create mode 100644 Samples~/Rig&Inputs.meta rename Samples~/{RigAndInputs => Rig&Inputs}/ML Rig.prefab (86%) rename Samples~/{RigAndInputs => Rig&Inputs}/ML Rig.prefab.meta (100%) rename Samples~/{RigAndInputs/MagicLeapInput.inputactions => Rig&Inputs/MagicLeapOpenXRInput.inputactions} (50%) rename Samples~/{RigAndInputs/MagicLeapInput.inputactions.meta => Rig&Inputs/MagicLeapOpenXRInput.inputactions.meta} (100%) create mode 100644 Tests/Runtime/Common/NativeRingBufferTests.cs create mode 100644 Tests/Runtime/Common/NativeRingBufferTests.cs.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ea0951..2ef9c44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,36 @@ # Changelog +## [2.1.0] + +### Features +- Update OpenXR Plugin dependency to `1.10.0`. +- Added `Magic Leap 2 Facial Expressions` OpenXR Feature. +- Added `Magic Leap 2 Environmental Meshing` OpenXR feature. +- Added `Magic Leap 2 Spatial Anchors` OpenXR Feature +- Added `Magic Leap 2 Spatial Anchors Storage` OpenXR Feature +- Added `MagicLeap.Android.Permissions`, a new and improved Permissions API. +- Included an AprilTagSettings struct to the `Magic Leap 2 Marker Understanding` OpenXR Feature + +### Experimental +- Added `AndroidCamera` APIs for performing basic YUV and JPEG Camera capture. + +### Bugfixes +- Fixed issue where JPEG screen capture with `MLCamera` was not displaying an image. +- Fixed legacy `MLPlanes` subsystem not being initialized when using Magic Leap XR Provider. +- Added project validation rules to check for Player Settings required by Magic Leap 2. +- Fixed `MLCVCamera` being unable to query Headpose from the MLSDK when the OpenXR PRovider is active. +- Fixed `MLMarkerTracker` issue where detected `AprilTag` markers are flipped. + +### Deprecations & Removals +- Removed Preferences>External Tools>Magic Leap. +- Marked `MLPermissions` Obsolete. Use `MagicLeap.Android.Permissions` instead. + +### Known Issues +- `MLAnchors` API does not work when the `Magic Leap 2 Spatial Anchors` or `Magic Leap 2 Spatial Anchors Storage` OpenXR Features are enabled. + +### Misc. +- Renamed the ML Rig & Inputs Sample input actions asset as well as the old `MagicLeapInputs` asset to make it clear what the differences are. + ## [2.0.0] ### Features diff --git a/Editor/APKBuilder.cs b/Editor/APKBuilder.cs index cb993c6..bf50ca1 100644 --- a/Editor/APKBuilder.cs +++ b/Editor/APKBuilder.cs @@ -15,13 +15,6 @@ public class APKBuilder private static readonly string Arg_ForceSDKPathFromEnvVar = "--force_sdk_path_from_env_var"; private static readonly string Arg_AppVersionCodeValue = "--version-code"; -#if !UNITY_2022_2_OR_NEWER - private static readonly Dictionary BuildTargetToGroup = new Dictionary() - { - { BuildTarget.Relish, BuildTargetGroup.Relish } - }; -#endif - private bool didSetSDKPathFromEnvVar = false; private class BuildSettingsCache @@ -71,15 +64,8 @@ private void Build() { throw new System.Exception("You must be on the Android Build Target to use APKBuilder."); } -#else - if (!BuildTargetToGroup.ContainsKey(EditorUserBuildSettings.activeBuildTarget)) - { - throw new System.Exception($"Unsupported build target {EditorUserBuildSettings.activeBuildTarget} for APKBuilder. Only Relish build target is supported."); - } #endif - SetupSDKPaths(System.Array.IndexOf(System.Environment.GetCommandLineArgs(), Arg_ForceSDKPathFromEnvVar) != -1); - BuildSettingsCache buildSettingsCache = new BuildSettingsCache(); try @@ -252,43 +238,6 @@ private bool TryGetArgValue(string arg, ref string value) return false; } - /// - /// Magic Leap SDK is required during the build process to include the - /// correct permissions in AndroidManifest.xml. - /// - /// - private void SetupSDKPaths(bool bForceSetFromEnvVar) - { - bool didSetFromEnvVar = false; - if (bForceSetFromEnvVar || !MagicLeapSDKUtil.SdkAvailable) - { - string relishSDKPath = System.Environment.GetEnvironmentVariable("RELISHSDK_UNITY"); - if (string.IsNullOrEmpty(relishSDKPath)) - { - Debug.LogWarning("No SDK path found for Relish in editor preferences or RELISHSDK_UNITY environment variable. Build will probably fail OR Magic Leap permissions will not be included in AndroidManifest.xml."); - } - else - { - if (bForceSetFromEnvVar) - { - Debug.LogFormat("{0} was passed as cmd line arg. Force setting Relish SDK Path to {1} from env vars.", Arg_ForceSDKPathFromEnvVar, relishSDKPath); - } - else - { - Debug.LogFormat("No SDK path set for Relish in editor preferences. Using {0} from env vars.", relishSDKPath); - } - MagicLeapSDKUtil.SdkPath = relishSDKPath; - didSetFromEnvVar = true; - } - } - else - { - Debug.LogFormat("Relish SDK found in editor preferences at {0}", MagicLeapSDKUtil.SdkPath); - } - - this.didSetSDKPathFromEnvVar = didSetFromEnvVar; - } - [Serializable] private class SimplePackageManifest { diff --git a/Editor/MLAppSim/AppSimShimLibSupport.cs b/Editor/MLAppSim/AppSimShimLibSupport.cs deleted file mode 100644 index dd2cec2..0000000 --- a/Editor/MLAppSim/AppSimShimLibSupport.cs +++ /dev/null @@ -1,114 +0,0 @@ -// %BANNER_BEGIN% -// --------------------------------------------------------------------- -// %COPYRIGHT_BEGIN% -// Copyright (c) (2021-2022) 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.Collections.Generic; -using System.IO; -using UnityEngine; -using System.Linq; -using UnityEngine.XR.MagicLeap; -using UnityEngine.XR.Management; -using UnityEditor.XR.Management; -#if UNITY_OPENXR_1_9_0_OR_NEWER -using UnityEngine.XR.OpenXR; -#endif - -namespace UnityEditor.XR.MagicLeap -{ - public static class AppSimShimLibSupport - { - private static string LaunchProcess => Path.Combine(MagicLeapSDKUtil.AppSimRuntimePath, "bin/ZIDiscovery"); - - public static readonly string SessionStateKey_ZISearchPaths = "ZI_SEARCH_PATHS"; - private static List libSearchPaths = new List(); - - /// - /// Gets called before the XR Loader starts initializing all the subsystems. - /// Runs ZIDiscovery.exe to get the list of folders where the ZI shim - /// libs reside and sends them to the SDK loader lib. - /// - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] - private static void CheckForLibrarySearchPaths() - { - var settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Standalone); - if (settings == null || settings.Manager == null ) - { - return; - } - - bool foundSupportedLoader = false; -#if UNITY_XR_MAGICLEAP_PROVIDER - foundSupportedLoader = settings.Manager.activeLoaders.Any(l => l is MagicLeapLoader); -#elif UNITY_OPENXR_1_9_0_OR_NEWER - foundSupportedLoader = settings.Manager.activeLoaders.Any(l => l is OpenXRLoader); -#endif - - if (!foundSupportedLoader) - { - Debug.LogError("No supported XR loader found for AppSim"); - return; - } - - string cachedSearchPaths = SessionState.GetString(SessionStateKey_ZISearchPaths, string.Empty); - if (string.IsNullOrEmpty(cachedSearchPaths)) - { - var ziRuntime = MagicLeapSDKUtil.AppSimRuntimePath; - if (string.IsNullOrEmpty(ziRuntime)) - { - Debug.LogError("Zero Iteration Runtime path is not set."); - SettingsService.OpenUserPreferences("Preferences/External Tools/Magic Leap"); - return; - } - -#if UNITY_EDITOR_WIN - ziRuntime = ziRuntime.Replace("/", "\\"); -#endif - var startInfo = new System.Diagnostics.ProcessStartInfo - { - UseShellExecute = false, - FileName = LaunchProcess, - Arguments = $"-m\"{MagicLeapSDKUtil.SdkPath}\" -p", - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true - }; - - var discoveryProc = new System.Diagnostics.Process(); - discoveryProc.EnableRaisingEvents = true; - discoveryProc.StartInfo = startInfo; - - discoveryProc.Start(); - - StreamReader outputStream = discoveryProc.StandardOutput; - - string output = outputStream.ReadToEnd(); - - discoveryProc.WaitForExit(); - - if (discoveryProc.ExitCode != 0) - { - StreamReader errorStream = discoveryProc.StandardError; - var error = errorStream.ReadToEnd(); - Debug.LogError($"ZIDiscovery returned with code {discoveryProc.ExitCode}: {error}"); - return; - } - - libSearchPaths = new List(output.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); - SessionState.SetString(SessionStateKey_ZISearchPaths, string.Join(Path.PathSeparator, libSearchPaths)); - } - else - { - libSearchPaths = new List(cachedSearchPaths.Split(Path.PathSeparator)); - } - - MagicLeapXrProvider.AddLibrarySearchPaths(libSearchPaths, settings.Manager.activeLoaders); - } - } -} diff --git a/Editor/MLAppSim/LabDriverControl.cs b/Editor/MLAppSim/LabDriverControl.cs deleted file mode 100644 index 0f816a9..0000000 --- a/Editor/MLAppSim/LabDriverControl.cs +++ /dev/null @@ -1,431 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using UnityEditor; -using UnityEditor.UIElements; -using UnityEngine; -using UnityEngine.Rendering; -using UnityEngine.UIElements; - -namespace UnityEditor.XR.MagicLeap -{ - public class LabDriverControl : EditorWindow - { - private IMGUIContainer _remoteChecksUi; - private VisualElement _mainVisualContainer; - - private string[] _availablePackages = new string[] { }; - - internal static StringBuilder s_LabdriverLog = new StringBuilder(); - internal static StringBuilder s_LabdriverErrorLog = new StringBuilder(); - - internal static bool s_LabdriverIsRunning = false; - internal static bool s_LabdriverExit = false; - internal static bool s_LabdriverOutputDone = false; - internal static bool s_LabdriverIsImport = false; - internal static Action s_LabdriverOnComplete = null; - - private static int progressId; - - private static Process s_Process; - - internal class JSONObject - { - public List results = null; - public bool success; - } - - [Serializable] - internal class JSONResult - { - public List output = null; - public List error = null; - } - - private void OnDisable() - { - } - - private void OnEnable() - { - _remoteChecksUi = new IMGUIContainer(OnRemoteChecksUI); - _mainVisualContainer = new VisualElement() - { - name = "MainVisualContainer" - }; - _mainVisualContainer.Add(_remoteChecksUi); - var root = this.rootVisualElement; - root.Add(_mainVisualContainer); - - _availablePackages = MagicLeapPackageLocator.GetUnityPackages().ToArray(); - } - - private void OnGUI() - { - - } - - private void OnRemoteChecksUI() - { - GUILayout.Label("Magic Leap App Simulator Requirements", EditorStyles.boldLabel); - - using (new GUILayout.HorizontalScope()) - { - if (GUILayout.Button("Import MagicLeap unitypackage")) - { - var rect = GUILayoutUtility.GetLastRect(); - var versions = new GenericMenu(); - foreach (var pkg in _availablePackages) - { - versions.AddItem(new GUIContent(pkg), false, InstallPackage, pkg); - } - // show options as a drop down. - versions.DropDown(rect); - } - } - } - - //[MenuItem("Window/XR/MagicLeap Dashboard", false, 1)] - private static void Display() - { - // Get existing open window or if none, make a new one: - EditorWindow.GetWindow(false, "ML Dashboard").Show(); - } - - private void InstallPackage(object p) - { - var path = p as string; - UnityEngine.Debug.LogFormat("Importing: {0}", path); - AssetDatabase.ImportPackage(path, true); - } - - // EditorUtility.DisplayProgressbar must be called from the main thread - // Typically you would call it from OnGUI, but this class may not have its own GUI calls - // so instead we place it in the Editor's global update ticks. - private static void ShowProgressDialog() - { - if (s_LabdriverIsRunning) - { - EditorUtility.DisplayProgressBar("Magic Leap Hub", "Issuing command to Magic Leap Hub...", 1f); - } - else - { - EditorUtility.ClearProgressBar(); - EditorApplication.update -= ShowProgressDialog; - } - } - - internal static void LaunchLabDriver(List args, Action onComplete, bool importCommand = false, bool useVirtualDevice = false) - { - EditorApplication.update += ShowProgressDialog; - - s_LabdriverIsRunning = true; - s_LabdriverExit = false; - s_LabdriverOutputDone = false; - s_LabdriverLog.Clear(); - - var startInfo = new ProcessStartInfo - { - UseShellExecute = false, -#if UNITY_EDITOR_WIN - FileName = "cmd.exe", -#else // OSX or Linux - FileName = "/bin/sh", -#endif - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true - }; - - // copy arguments into new-style ArgumentList, which handles spaces properly -#if UNITY_EDITOR_WIN - // i.e. "cmd /C labdriver ..." runs this command rather than an interactive shell - startInfo.ArgumentList.Add("/C"); -#endif - foreach (string arg in args) - { - startInfo.ArgumentList.Add(arg); - } - - if (useVirtualDevice) - { - if (!startInfo.EnvironmentVariables.ContainsKey("ML_ZI_ROOT")) - { - startInfo.EnvironmentVariables.Add("ML_ZI_ROOT", MagicLeapSDKUtil.SdkPath + "/VirtualDevice"); - } - } - - s_Process = new System.Diagnostics.Process(); - s_Process.EnableRaisingEvents = true; - s_Process.OutputDataReceived += OnOutputReceived; - s_Process.Exited += OnProcessExit; - s_Process.ErrorDataReceived += OnErrorReceived; - s_Process.StartInfo = startInfo; - - s_LabdriverIsImport = importCommand; - s_LabdriverOnComplete = onComplete; - s_LabdriverLog.Clear(); - s_LabdriverErrorLog.Clear(); - - progressId = Progress.Start("Running labdriver process"); - - s_Process.Start(); - s_Process.BeginOutputReadLine(); - s_Process.BeginErrorReadLine(); - } - - private static void LaunchLabDriverCommand(List commands, Action onComplete) - { - var sdkPath = MagicLeapSDKUtil.SdkPath; - if (string.IsNullOrEmpty(sdkPath)) - { - UnityEngine.Debug.LogError("Magic Leap SDK path not configured!"); - return; - } - else if (!File.Exists(Path.Combine(sdkPath, "labdriver"))) - { - UnityEngine.Debug.LogErrorFormat("labdriver executable not found in configured SDK path \"{0}\"! Make sure the path is valid.", sdkPath); - return; - } - if (!s_LabdriverIsRunning) - { - UnityEngine.Debug.Log("Launching labdriver with: " + string.Join(" ", commands)); -#if UNITY_EDITOR_WIN - commands.InsertRange(0, new List{$"{sdkPath}/labdriver.cmd", "-pretty"}); -#else // OSX or Linux - commands.InsertRange(0, new List{$"{sdkPath}/labdriver", "-pretty"}); -#endif - LaunchLabDriver(commands, onComplete); - } - else - { - UnityEngine.Debug.Log("Previous Magic Leap Hub command is still running. Please wait until it completes."); - } - } - - private static void HandleLabDriverResult(bool success, string json) - { - if (!success) - { - UnityEngine.Debug.LogError("Magic Leap Hub command failed:\n" + json); - } - } - - [MenuItem("Magic Leap/Launch Magic Leap Hub")] - private static void LaunchHub() - { - LaunchLabDriverCommand(new List{"start-gui"}, HandleLabDriverResult); - } - - [MenuItem("Magic Leap/Save Diagnostic Logs...")] - private static void SaveLogs() - { - bool result = EditorUtility.DisplayDialog("Privacy Notice", - String.Concat( - "Create an error report file (.zip) to help us diagnose problems.\n\n", - "(Note: if you are using a Magic Leap device, please connect it now.)\n\n", - "Ask a question in the Magic Leap Developer Portal (https://developer.magicleap.cloud/support) " + - "and attach the error report .zip file.\n\n", - "Error reports are public, and the .zip file may contain identifying information, so you should inspect the .zip before sending.\n\n", - "See https://developer-docs.magicleap.cloud/docs/guides/developer-tools/ml-hub/error-reporting" - ), "Ok", "Cancel"); - if (!result) - { - return; - } - - string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss"); - string tempFile = $"MLHubLogs-{dateTime}.zip"; - string tempFileDir = Path.GetTempPath(); - string tempFilePath = Path.Combine(tempFileDir, tempFile); - - void OpenLogFile(bool success, string json) - { - if (!success) - { - HandleLabDriverResult(success, json); - return; - } - - // reveal file in explorer/finder - ProcessStartInfo startInfo = null; -#if UNITY_EDITOR_OSX - startInfo = new ProcessStartInfo - { - UseShellExecute = false, - FileName = "/usr/bin/open", - ArgumentList = { "-R", tempFilePath }, - CreateNoWindow = true - }; -#elif UNITY_EDITOR_WIN - startInfo = new ProcessStartInfo - { - UseShellExecute = false, - FileName = "explorer.exe", - ArgumentList = { "/select,", tempFilePath }, // the embedded comma is needed - CreateNoWindow = true - }; -#endif - if (startInfo != null) - { - var process = new System.Diagnostics.Process(); - process.StartInfo = startInfo; - process.Start(); - } - } - - LaunchLabDriverCommand(new List{"save-logs", tempFilePath}, OpenLogFile); - } - - private static void WaitForComplete() - { - // Confirm the process has exited and the output has completed before processing logs. - if (s_LabdriverExit && s_LabdriverOutputDone) - { - s_Process.CancelErrorRead(); - s_Process.CancelOutputRead(); - String finalResult = s_LabdriverLog.ToString(); - - s_LabdriverIsRunning = false; - - Progress.Report(progressId, 1.0f); - - if (!String.IsNullOrEmpty(finalResult)) - { - JSONObject fullLog = JsonUtility.FromJson(finalResult); - - if (!fullLog.success) - { - ProcessLogs(fullLog); - } - else if (s_LabdriverIsImport) - { - IEnumerable ZILibraries = fullLog.results[0].output; - - // TODO : Lib discovery is no longer run via LabDriverControl. - // Refactor this class to remove unnecesarry code. - //ZeroIterationImportSupport.DiscoveryReturned(ZILibraries); - } - - Progress.Remove(progressId); - - if (s_LabdriverOnComplete != null) - { - // success - s_LabdriverOnComplete(true, finalResult); - } - } - else - { - String finalError = s_LabdriverErrorLog.ToString(); - - Progress.Remove(progressId); - - if (s_LabdriverOnComplete != null) - { - // failure - s_LabdriverOnComplete(false, finalError); - } - } - - s_LabdriverIsImport = false; - s_LabdriverOnComplete = null; - } - } - - private static void OnOutputReceived(object sender, DataReceivedEventArgs e) - { - if (!String.IsNullOrEmpty(e.Data)) - { - s_LabdriverLog.Append(e.Data); - - string statusCheck = s_LabdriverLog.ToString(); - - if ((statusCheck.Substring(statusCheck.Length - 1, 1) == "}") && statusCheck.Contains("\"success\":")) - { - s_LabdriverOutputDone = true; - WaitForComplete(); - } - s_LabdriverLog.Append(' '); - } - else - { - if (!s_LabdriverOutputDone) - { - s_LabdriverOutputDone = true; - WaitForComplete(); - } - } - } - - private static void OnErrorReceived(object sender, DataReceivedEventArgs e) - { - if (!String.IsNullOrEmpty(e.Data)) - { - s_LabdriverErrorLog.Append(e.Data); - s_LabdriverErrorLog.Append(' '); - } - } - - private static void OnProcessExit(object sender, EventArgs e) - { - s_LabdriverExit = true; - - WaitForComplete(); - } - - private static void ProcessLogs(JSONObject currentLogs) - { - string logToPrint = ""; - - foreach (JSONResult result in currentLogs.results) - { - foreach (string item in result.error) - { - if (!String.IsNullOrEmpty(item)) - { - logToPrint += "\n" + item; - } - } - } - - if (String.IsNullOrEmpty(logToPrint) || s_LabdriverIsImport) - { - String currentAction = s_LabdriverIsImport ? "import support libraries" : "launch Magic Leap App Simulator"; - logToPrint = String.Format("Magic Leap Hub encountered an unknown error while attempting to {0}. " + - "Please confirm Magic Leap Hub in installed and up to date with the Magic Leap App Simulator Module and " + - "Magic Leap App Simulator Runtime package installed.\n", currentAction) + logToPrint; - } - - String finalLog = "labdriver completed with errors. \nErrors:" + logToPrint; - - UnityEngine.Debug.LogError(finalLog); - } - } - - - internal static class MagicLeapPackageLocator - { - public static IEnumerable GetUnityPackages() - { - var tools = Path.Combine(MagicLeapRoot, "tools"); - return new DirectoryInfo(tools).GetFiles("*.unitypackage", SearchOption.AllDirectories).Select(fi => fi.FullName); - } - - private static string HomeFolder - { - get - { - var home = Environment.GetEnvironmentVariable("USERPROFILE"); - return (string.IsNullOrEmpty(home)) - ? Environment.GetEnvironmentVariable("HOME") - : home; - } - } - - public static string MagicLeapRoot { get { return Path.Combine(HomeFolder, "MagicLeap"); } } - } -} diff --git a/Editor/MagicLeapSDKUtil.cs b/Editor/MagicLeapSDKUtil.cs index e84b6d9..4568752 100644 --- a/Editor/MagicLeapSDKUtil.cs +++ b/Editor/MagicLeapSDKUtil.cs @@ -19,11 +19,7 @@ public sealed class MagicLeapSDKUtil { private const string kManifestPath = ".metadata/sdk.manifest"; private const string kMagicLeapSDKRoot = "MagicLeapSDKRoot"; -#if UNITY_2022_2_OR_NEWER private const UnityEditor.BuildTarget kBuildTarget = BuildTarget.Android; -#else - private const UnityEditor.BuildTarget kBuildTarget = BuildTarget.Relish; -#endif private static uint minApiLevel = 0; [Serializable] @@ -42,9 +38,10 @@ public static bool SdkAvailable { get { - if (string.IsNullOrEmpty(SdkPath)) + var path = SdkPath; + if (string.IsNullOrEmpty(path)) return false; - return File.Exists(Path.Combine(SdkPath, kManifestPath)); + return Directory.Exists(path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)); } } @@ -69,7 +66,7 @@ public static uint MinimumApiLevel } /// - /// MLSDK path for the relish target. + /// MLSDK path for the android target. /// public static string SdkPath { @@ -77,14 +74,6 @@ public static string SdkPath set { SetSDKPath(kBuildTarget, value); } } - public static string AppSimRuntimePath => MagicLeapEditorPreferences.ZeroIterationRuntimePath; - public static bool SearchingForZI => MagicLeapEditorPreferences.RunningLabdriver; - public static event Action OnZeroIterationPathChanged - { - add { MagicLeapEditorPreferences.ZIRuntimePathChangeEvt += value; } - remove { MagicLeapEditorPreferences.ZIRuntimePathChangeEvt -= value; } - } - /// /// MLSDK version /// @@ -105,7 +94,7 @@ public static void DeleteSDKPathFromEditorPrefs(BuildTarget target) /// /// Get the MLSDK path for the given build target platform. /// - /// Relish is the only valid target for now. + /// Android is the only valid target for now. /// private static string GetSDKPath(BuildTarget target) { diff --git a/Editor/OpenXR/MagicLeapFeatureGroup.cs b/Editor/OpenXR/MagicLeapFeatureGroup.cs index c62c78a..e40e2a5 100644 --- a/Editor/OpenXR/MagicLeapFeatureGroup.cs +++ b/Editor/OpenXR/MagicLeapFeatureGroup.cs @@ -9,18 +9,18 @@ // %BANNER_END% #if UNITY_OPENXR_1_9_0_OR_NEWER -using UnityEditor; -using UnityEditor.XR.OpenXR.Features; +using UnityEngine.XR.OpenXR.Features.MagicLeapSupport; -namespace UnityEngine.XR.OpenXR.Features.MagicLeapSupport +namespace UnityEditor.XR.OpenXR.Features.MagicLeapSupport { [OpenXRFeatureSet( UiName = "Magic Leap", - Description = "All Magic Leap OpenXR Features", + Description = "Features supported by the Magic Leap 2 platform.", FeatureSetId = "com.magicleap.openxr.featuregroup", - SupportedBuildTargets = new [] { BuildTargetGroup.Android, BuildTargetGroup.Standalone }, - FeatureIds = new [] { - MagicLeapFeature.FeatureId , + SupportedBuildTargets = new [] { BuildTargetGroup.Android }, + FeatureIds = new[] { + MagicLeapFeature.FeatureId, + MagicLeapControllerProfile.FeatureId, MagicLeapRenderingExtensionsFeature.FeatureId, MagicLeapReferenceSpacesFeature.FeatureId, MagicLeapPlanesFeature.FeatureId, @@ -28,22 +28,60 @@ namespace UnityEngine.XR.OpenXR.Features.MagicLeapSupport MagicLeapSystemNotificationsFeature.FeatureId, MagicLeapMarkerUnderstandingFeature.FeatureId, MagicLeapLocalizationMapFeature.FeatureId, - MagicLeapSpatialAnchorsFeature.FeatureId - }, - RequiredFeatureIds = new[] { - MagicLeapFeature.FeatureId + MagicLeapSpatialAnchorsFeature.FeatureId, + MagicLeapSpatialAnchorsStorageFeature.FeatureId, + MagicLeapFacialExpressionFeature.FeatureId, + MagicLeapMeshingFeature.FeatureId }, DefaultFeatureIds = new[] { + MagicLeapFeature.FeatureId, + MagicLeapControllerProfile.FeatureId, + MagicLeapRenderingExtensionsFeature.FeatureId, + MagicLeapReferenceSpacesFeature.FeatureId, + MagicLeapPlanesFeature.FeatureId, + MagicLeapUserCalibrationFeature.FeatureId, + MagicLeapSystemNotificationsFeature.FeatureId, + MagicLeapMarkerUnderstandingFeature.FeatureId, + MagicLeapLocalizationMapFeature.FeatureId, + MagicLeapSpatialAnchorsFeature.FeatureId, + MagicLeapSpatialAnchorsStorageFeature.FeatureId, + MagicLeapFacialExpressionFeature.FeatureId, + MagicLeapMeshingFeature.FeatureId + } + )] + public class MagicLeapFeatureGroup { } + +#if UNITY_EDITOR_WIN + [OpenXRFeatureSet( + UiName = "Magic Leap AppSim", + Description = "All features supported by the Magic Leap 2 platform.", + FeatureSetId = "com.magicleap.openxr.featuregroup.appsim", + SupportedBuildTargets = new[] { BuildTargetGroup.Standalone }, + FeatureIds = new[] { + MagicLeapFeature.FeatureId, + MagicLeapControllerProfile.FeatureId, MagicLeapRenderingExtensionsFeature.FeatureId, MagicLeapReferenceSpacesFeature.FeatureId, MagicLeapPlanesFeature.FeatureId, MagicLeapUserCalibrationFeature.FeatureId, MagicLeapSystemNotificationsFeature.FeatureId, MagicLeapMarkerUnderstandingFeature.FeatureId, - MagicLeapLocalizationMapFeature.FeatureId + MagicLeapLocalizationMapFeature.FeatureId, + MagicLeapSpatialAnchorsFeature.FeatureId, + MagicLeapSpatialAnchorsStorageFeature.FeatureId, + MagicLeapFacialExpressionFeature.FeatureId, + MagicLeapMeshingFeature.FeatureId + }, + DefaultFeatureIds = new[] { + MagicLeapFeature.FeatureId, + MagicLeapControllerProfile.FeatureId, + MagicLeapPlanesFeature.FeatureId, + MagicLeapMarkerUnderstandingFeature.FeatureId, + MagicLeapSpatialAnchorsFeature.FeatureId, + MagicLeapMeshingFeature.FeatureId } )] - public class MagicLeapFeatureGroup - { } +#endif + public class MagicLeapFeatureAppSimGroup { } } #endif diff --git a/Editor/OpenXR/MagicLeapRenderingExtensionsFeatureEditor.cs b/Editor/OpenXR/MagicLeapRenderingExtensionsFeatureEditor.cs new file mode 100644 index 0000000..876ad40 --- /dev/null +++ b/Editor/OpenXR/MagicLeapRenderingExtensionsFeatureEditor.cs @@ -0,0 +1,55 @@ +// %BANNER_BEGIN% +// --------------------------------------------------------------------- +// %COPYRIGHT_BEGIN% +// Copyright (c) (2019-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 UnityEditor; +using UnityEngine.XR.OpenXR.Features.MagicLeapSupport; +using UnityEngine.XR.OpenXR.NativeTypes; + +#if UNITY_OPENXR_1_9_0_OR_NEWER +[CustomEditor(typeof(MagicLeapRenderingExtensionsFeature))] +public class MagicLeapRenderingExtensionsFeatureEditor : Editor +{ + private SerializedProperty protectedSurfaceProperty; + private SerializedProperty vignetteProperty; + private SerializedProperty blendModeProperty; + private SerializedProperty globalDimmerProperty; + private SerializedProperty globalDimmerValueProperty; + + private enum SupportedBlendModes + { + Additive = XrEnvironmentBlendMode.Additive, + AlphaBlend = XrEnvironmentBlendMode.AlphaBlend + } + + private void OnEnable() + { + blendModeProperty = serializedObject.FindProperty("BlendMode"); + protectedSurfaceProperty = serializedObject.FindProperty("UseProtectedSurface"); + vignetteProperty = serializedObject.FindProperty("UseVignetteMode"); + globalDimmerProperty = serializedObject.FindProperty("GlobalDimmerEnabled"); + globalDimmerValueProperty = serializedObject.FindProperty("GlobalDimmerValue"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + blendModeProperty.intValue = (int)(SupportedBlendModes) EditorGUILayout.EnumPopup("Blend Mode", (SupportedBlendModes)blendModeProperty.intValue); + protectedSurfaceProperty.boolValue = EditorGUILayout.Toggle("Protected Surface", protectedSurfaceProperty.boolValue); + vignetteProperty.boolValue = EditorGUILayout.Toggle("Vignette", vignetteProperty.boolValue); + globalDimmerProperty.boolValue = EditorGUILayout.Toggle("Enable Global Dimmer", globalDimmerProperty.boolValue); + + var dimmerEnabled = globalDimmerProperty.boolValue; + globalDimmerValueProperty.floatValue = EditorGUILayout.Slider("Global Dimmer Value", dimmerEnabled ? globalDimmerValueProperty.floatValue : 0f, 0f, 1f); + + serializedObject.ApplyModifiedProperties(); + } +} +#endif diff --git a/Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.cs.meta b/Editor/OpenXR/MagicLeapRenderingExtensionsFeatureEditor.cs.meta similarity index 83% rename from Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.cs.meta rename to Editor/OpenXR/MagicLeapRenderingExtensionsFeatureEditor.cs.meta index 4ee88bf..eceb268 100644 --- a/Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.cs.meta +++ b/Editor/OpenXR/MagicLeapRenderingExtensionsFeatureEditor.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 99ce30e5b1edc124b8e4e0b12a5bac03 +guid: bc0418a2644a443cd8ebc8031c2c0cd8 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Editor/SettingsProviders/Permissions/PermissionSettingsLoader.cs b/Editor/SettingsProviders/Permissions/PermissionSettingsLoader.cs index 5daba57..9c8456c 100644 --- a/Editor/SettingsProviders/Permissions/PermissionSettingsLoader.cs +++ b/Editor/SettingsProviders/Permissions/PermissionSettingsLoader.cs @@ -14,9 +14,10 @@ namespace UnityEditor.XR.MagicLeap { - public class PermissionSettingsLoader + internal class PermissionSettingsLoader { - private string FilePath => Path.Combine(MagicLeapSDKUtil.SdkPath, "data", "ml_permissions.json"); + private const string manifestFileName = "ml_permissions.json"; + public string ManifestFilePath => Path.Combine("Packages/com.magicleap.unitysdk/Editor/SettingsProviders/Permissions/data~", manifestFileName); internal PermissionsListJson settingJson { get; private set; } public PermissionSettingsLoader() => Initialize(); @@ -25,7 +26,7 @@ private void Initialize() { try { - var json = File.ReadAllText(FilePath, Encoding.UTF8); + var json = File.ReadAllText(ManifestFilePath, Encoding.UTF8); settingJson = JsonUtility.FromJson($"{{\"Settings\":{json}}}"); } diff --git a/Editor/SettingsProviders/Permissions/data~/ml_permissions.json b/Editor/SettingsProviders/Permissions/data~/ml_permissions.json new file mode 100644 index 0000000..0018979 --- /dev/null +++ b/Editor/SettingsProviders/Permissions/data~/ml_permissions.json @@ -0,0 +1,93 @@ +[ + { + "name": "android.permission.CAMERA", + "description": "Permission to use device camera(s).", + "level": "dangerous", + "min_api_level": 20 + }, + { + "name": "android.permission.RECORD_AUDIO", + "description": "Permission to use device microphone to record audio.", + "level": "dangerous", + "min_api_level": 20 + }, + { + "name": "com.magicleap.permission.EYE_TRACKING", + "description": "Permission to obtain eye tracking data.", + "level": "dangerous", + "min_api_level": 9 + }, + { + "name": "com.magicleap.permission.PUPIL_SIZE", + "description": "Permission to obtain eye pupil size data.", + "level": "dangerous", + "min_api_level": 20 + }, + { + "name": "com.magicleap.permission.SPATIAL_ANCHOR", + "description": "Permission to obtain spatial anchor(s) data.", + "level": "normal", + "min_api_level": 20 + }, + { + "name": "com.magicleap.permission.HAND_TRACKING", + "description": "Permission to obtain hand tracking data.", + "level": "normal", + "min_api_level": 20 + }, + { + "name": "com.magicleap.permission.WEBVIEW", + "description": "Permission to enable WebView access.", + "level": "normal", + "min_api_level": 20 + }, + { + "name": "com.magicleap.permission.MARKER_TRACKING", + "description": "Permission to obtain marker tracking data.", + "level": "normal", + "min_api_level": 20 + }, + { + "name": "com.magicleap.permission.VOICE_INPUT", + "description": "Permission to obtain voice input data.", + "level": "dangerous", + "min_api_level": 20 + }, + { + "name": "com.magicleap.permission.SPATIAL_MAPPING", + "description": "Permission to obtain following spatial data: planes data, meshing data.", + "level": "dangerous", + "min_api_level": 20 + }, + { + "name": "com.magicleap.permission.DEPTH_CAMERA", + "description": "Permission to use depth camera.", + "level": "dangerous", + "min_api_level": 23 + }, + { + "name": "com.magicleap.permission.EYE_CAMERA", + "description": "Permission to use eye cameras.", + "level": "dangerous", + "min_api_level": 26 + }, + { + "name": "com.magicleap.permission.SPACE_MANAGER", + "description": "Permission to use Magic Leap Space manager.", + "level": "normal", + "min_api_level": 26 + }, + { + "name": "com.magicleap.permission.SPACE_IMPORT_EXPORT", + "description": "Permission to export and import Magic Leap Spaces.", + "level": "dangerous", + "min_api_level": 26 + }, + { + "name": "com.magicleap.permission.FACIAL_EXPRESSION", + "description": "Permission to obtain facial expression data.", + "level": "dangerous", + "min_api_level": 29 + } + +] diff --git a/Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.cs b/Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.cs deleted file mode 100644 index d3a960b..0000000 --- a/Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.cs +++ /dev/null @@ -1,471 +0,0 @@ -using System.Collections.Generic; -using UnityEngine.UIElements; -using System.IO; -using UnityEngine.XR.MagicLeap; -using System.Diagnostics; -using System.Threading.Tasks; -using System; - -namespace UnityEditor.XR.MagicLeap -{ - internal static class MagicLeapEditorPreferences - { - private static readonly string SdkPathEditorPrefsKey = "MagicLeapSDKRoot"; - private static readonly string UserCustomZIBackendPath = "ZI_User_Selected_ZI_Runtime"; - private static readonly string LabdriverFoundBackendPath = "ZI_Labdriver_Found_ZI_Runtime"; - private static readonly string ToggleZIPathEnableOverride = "ZI_Path_Enable_Override"; - - private static readonly string PathToUIAsset = "Packages/com.magicleap.unitysdk/Editor/SettingsProviders/Preferences/MagicLeapEditorPreferences.uxml"; - - private static TextField sdkInputField; - private static TextField ziInputField; - private static Button sdkPathBrowseBtn; - private static Button ziPathBrowseBtn; - private static VisualElement sdkPathHelpContainer; - private static VisualElement ziPathHelpContainer; - private static HelpBox sdkPathHelp; - private static HelpBox ziPathHelp; - private static Toggle ziPathOverrideToggle; - - private static bool labdriverRunning = false; - private static int progressId = -1; - - private static string mlsdkPath = ""; - private static string ziRuntimePath; - private static string labdriverResultPath = ""; - private static bool enableOverrideZiPath; - private static bool usingLabdriverFoundPath = false; - - public static string ZeroIterationRuntimePath => ziRuntimePath; - - public static bool RunningLabdriver => labdriverRunning; - - public static event Action ZIRuntimePathChangeEvt; - - [InitializeOnLoad] - class PreferencesLoader - { - static PreferencesLoader() - { - var path = GetSavedSDKPath(); - if (Directory.Exists(path)) - { - mlsdkPath = path; - } - enableOverrideZiPath = EditorPrefs.GetBool(ToggleZIPathEnableOverride); - if (enableOverrideZiPath) - { - path = EditorPrefs.GetString(UserCustomZIBackendPath); - if (Directory.Exists(path)) - { - ziRuntimePath = path; - } - } - else - { - LocateZIRuntimeFromMLSDK(); - } - - EditorApplication.update += () => - { - if (!string.IsNullOrEmpty(labdriverResultPath)) - { - EditorPrefs.SetString(LabdriverFoundBackendPath, labdriverResultPath); - if (ziRuntimePath != labdriverResultPath) - { - ziRuntimePath = labdriverResultPath; - ZIRuntimePathChangeEvt?.Invoke(ziRuntimePath); - } - labdriverResultPath = ""; - } - if (labdriverRunning) - { - Progress.Report(progressId, 1f, "Searching for latest ML App Sim installation..."); - } - else - { - progressId = Progress.Remove(progressId); - } - }; - } - } - - [SettingsProvider] - public static SettingsProvider CreateMLPreferencesTabProvider() - { - var provider = new SettingsProvider("Preferences/External Tools/Magic Leap", SettingsScope.User) - { - label = "Magic Leap", - - // activateHandler is called when the user clicks on the Settings item in the Settings window. - activateHandler = (searchContext, rootElement) => - { - var visualTree = AssetDatabase.LoadAssetAtPath(PathToUIAsset); - - visualTree.CloneTree(rootElement); - - sdkInputField = rootElement.Q("MLSDK-Input"); - ziInputField = rootElement.Q("ZI-Input"); - sdkPathBrowseBtn = rootElement.Q