Exemplo n.º 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);
        }
Exemplo n.º 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
        }
Exemplo n.º 3
0
        /// <summary>
        /// Cleans up the component.
        /// </summary>
        void OnDestroy()
        {
            if (_privilegesBeingRequested)
            {
                _privilegesBeingRequested = false;

                MLPrivilegesStarterKit.Stop();
            }
        }
        /// <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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Responds to privilege requester result.
        /// </summary>
        /// <param name="result"/>
        private void HandlePrivilegesDone(MLResult result)
        {
            _privilegesBeingRequested = false;
            MLPrivilegesStarterKit.Stop();

            #if PLATFORM_LUMIN
            if (result != MLResult.Code.PrivilegeGranted)
            {
                Debug.LogErrorFormat("Error: ImageCaptureExample failed to get requested privileges, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }
            #endif

            Debug.Log("Succeeded in requesting all privileges");
            StartCapture();
        }
Exemplo n.º 6
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);
        }