Example #1
0
        /// <summary>
        /// Set correct render mode for meshing and update meshing settings.
        /// </summary>
        void Start()
        {
            #if PLATFORM_LUMIN
            // Assure that if the 'WorldReconstruction' privilege is missing, then it is logged for all users.
            MLResult result = MLPrivilegesStarterKit.Start();
            if (result.IsOk)
            {
                result = MLPrivilegesStarterKit.CheckPrivilege(MLPrivileges.Id.WorldReconstruction);
                if (result.Result != MLResult.Code.PrivilegeGranted)
                {
                    Debug.LogErrorFormat("Error: MeshingExample failed to create Mesh Subsystem due to missing 'WorldReconstruction' privilege. Please add to manifest. Disabling script.");
                    enabled = false;
                    return;
                }
                MLPrivilegesStarterKit.Stop();
            }
            else
            {
                Debug.LogErrorFormat("Error: MeshingExample failed starting MLPrivileges, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }
            #endif

            _meshingBehavior.gameObject.transform.position   = _camera.gameObject.transform.position;
            _meshingBehavior.gameObject.transform.localScale = _bounded ? _boundedExtentsSize : _boundlessExtentsSize;

            _visualBounds.SetActive(_bounded);
        }
Example #2
0
        /// <summary>
        /// Requests privileges and starts MLContacts.
        /// </summary>
        private void StartAPI()
        {
            #if PLATFORM_LUMIN
            MLResult result = MLPrivilegesStarterKit.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLContactsBehavior failed starting MLPrivileges, disabling script. Reason: {0}", result);
                OnStartupComplete?.Invoke(false);
                enabled = false;
                return;
            }

            result = MLPrivilegesStarterKit.RequestPrivileges(MLPrivileges.Id.AddressBookRead, MLPrivileges.Id.AddressBookWrite);
            if (result.Result != MLResult.Code.PrivilegeGranted)
            {
                Debug.LogErrorFormat("Error: MLContactsBehavior failed requesting privileges, disabling script. Reason: {0}", result);
                OnStartupComplete?.Invoke(false);
                enabled = false;
                return;
            }

            MLPrivilegesStarterKit.Stop();

            result = MLContacts.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLContactsBehavior failed starting MLContacts, disabling script. Reason: {0}", result);
                OnStartupComplete?.Invoke(false);
                enabled = false;
                return;
            }

            OnStartupComplete?.Invoke(true);
            #endif
        }
        /// <summary>
        /// Using Awake so that Privileges is set before PrivilegeRequester Start.
        /// </summary>
        void Awake()
        {
            if (_controllerConnectionHandler == null)
            {
                Debug.LogError("Error: ImageCaptureExample._controllerConnectionHandler is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_statusText == null)
            {
                Debug.LogError("Error: ImageCaptureExample._statusText is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_previewObject == null)
            {
                Debug.LogError("Error: ImageCaptureExample._previewObject is not set, disabling script.");
                enabled = false;
                return;
            }

            // This is made active when we have a captured image to show.
            _previewObject.SetActive(false);

            // Before enabling the Camera, the scene must wait until the privilege has been granted.
            MLResult result = MLPrivilegesStarterKit.Start();

            #if PLATFORM_LUMIN
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: ImageCaptureExample failed starting MLPrivilegesStarterKit, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }
            #endif

            result = MLPrivilegesStarterKit.RequestPrivilegesAsync(HandlePrivilegesDone, MLPrivileges.Id.CameraCapture);
            #if PLATFORM_LUMIN
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: ImageCaptureExample failed requesting privileges, disabling script. Reason: {0}", result);
                MLPrivilegesStarterKit.Stop();
                enabled = false;
                return;
            }
            #endif

            _privilegesBeingRequested = true;


            classes_filepath = Utils.getFilePath("dnn/" + classes);
            input_filepath   = Utils.getFilePath("dnn/" + input);
            config_filepath  = Utils.getFilePath("dnn/" + config);
            model_filepath   = Utils.getFilePath("dnn/" + model);
        }
Example #4
0
        /// <summary>
        /// Set correct render mode for meshing and update meshing settings.
        /// </summary>
        void Start()
        {
            #if PLATFORM_LUMIN
            // Assure that if the 'WorldReconstruction' privilege is missing, then it is logged for all users.
            MLResult result = MLPrivilegesStarterKit.Start();
            if (result.IsOk)
            {
                result = MLPrivilegesStarterKit.CheckPrivilege(MLPrivileges.Id.WorldReconstruction);
                if (result.Result != MLResult.Code.PrivilegeGranted)
                {
                    Debug.LogErrorFormat("Error: MeshingExample failed to create Mesh Subsystem due to missing 'WorldReconstruction' privilege. Please add to manifest. Disabling script.");
                    enabled = false;
                    return;
                }
                MLPrivilegesStarterKit.Stop();
            }
            else
            {
                Debug.LogErrorFormat("Error: MeshingExample failed starting MLPrivileges, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            result = MLHeadTracking.Start();
            if (result.IsOk)
            {
                MLHeadTracking.RegisterOnHeadTrackingMapEvent(OnHeadTrackingMapEvent);
            }
            else
            {
                Debug.LogError("MeshingExample could not register to head tracking events because MLHeadTracking could not be started.");
            }
            #endif

            _meshingVisualizer.SetRenderers(_renderMode);

            _mlSpatialMapper.gameObject.transform.position   = _camera.gameObject.transform.position;
            _mlSpatialMapper.gameObject.transform.localScale = _bounded ? _boundedExtentsSize : _boundlessExtentsSize;

            _visualBounds.SetActive(_bounded);
        }