/// <summary>
        /// Updates the world scale using the latest units.
        /// </summary>
        public void UpdateWorldScale()
        {
            float newScale = (Measurement == ScaleMeasurement.CustomUnits) ? CustomValue : (float)Measurement;

            if (newScale != _scale)
            {
                _scale = (Measurement == ScaleMeasurement.CustomUnits) ? CustomValue : (float)Measurement;

                float previousWorldScale = ContentParent.lossyScale.x;

                // Update the world scale on the main camera's parent.
                ContentParent.localScale = new Vector3(_scale, _scale, _scale);

                float newWorldScale = ContentParent.lossyScale.x;

                // Calculate the updated clip distances based on the world scale.
                // Assumes the original clip distances are in meters.
                Camera mainCamera = Camera.main;
                mainCamera.nearClipPlane = mainCamera.nearClipPlane / previousWorldScale * newWorldScale;
                mainCamera.farClipPlane  = mainCamera.farClipPlane / previousWorldScale * newWorldScale;

                #if PLATFORM_LUMIN
                // Notify the MLDevice the scale has changed.
                MLDevice.UpdateWorldScale();
                #endif
            }

            OnUpdateEvent?.Invoke(Scale, Units);
        }
Esempio n. 2
0
        /// <summary>
        /// Cannot make the assumption that a privilege is still granted after
        /// returning from pause. Return the application to the state where it
        /// requests privileges needed.
        /// </summary>
        void OnApplicationPause(bool pause)
        {
            if (pause)
            {
                MLImageTrackerStarterKit.Stop();
            }

            #if PLATFORM_LUMIN
            else if (MLDevice.IsReady() && _imageTarget != null)
            {
                MLImageTrackerStarterKit.Start();
            }
            #endif
        }
Esempio n. 3
0
            /// <summary>
            /// Request a new page
            /// </summary>
            /// <param name="pageLength">The length of the page.</param>
            /// <param name="offset">Offset into the page.</param>
            /// <returns>
            /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successfully submitted
            /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if either of the parameters are invalid.
            /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if necessary privilege is missing.
            /// </returns>
            protected override MLResult InternalNewPage(uint pageLength, string offset)
            {
                MLResult.Code resultCode = MLContacts.GetSearch(this.searchQuery, this.searchFields, pageLength, offset, out ulong handle);
                this.RequestHandle = handle;

                if (resultCode != MLResult.Code.Ok)
                {
                    this.Status = PageStatus.Failed;
                    return(MLResult.Create(MLResult.Code.Ok));
                }

                this.Status = PageStatus.Pending;
                MLDevice.RegisterUpdate(this.Update);
                this.UnregisterUpdate = true;

                return(MLResult.Create(MLResult.Code.Ok));
            }
Esempio n. 4
0
        public override void Update()
        {
#if PLATFORM_LUMIN
            // Ensure input is active
#if !UNITY_EDITOR
            if (MLDevice.IsReady())
#endif
            {
#if !UNITY_EDITOR
                UpdateHand(MLHandTracking.Right, Handedness.Right);
                UpdateHand(MLHandTracking.Left, Handedness.Left);
#endif
                foreach (MLControllerContainer controllerContainer in ConnectedControllers.Values)
                {
                    controllerContainer.mrtkController.UpdatePoses();
                }
            }
#endif
        }
Esempio n. 5
0
        public override void Update()
        {
            if (!IsEnabled)
            {
                return;
            }

#if PLATFORM_LUMIN
            // Ensure input is active
            if (MLDevice.IsReady())
            {
                UpdateHands();

                foreach (MLControllerContainer controllerContainer in ConnectedControllers.Values)
                {
                    controllerContainer.mrtkController.UpdatePoses();
                }
            }
#endif
        }
Esempio n. 6
0
 /// <summary>
 /// Must check for privileges again after pause.
 /// </summary>
 void OnApplicationPause(bool pause)
 {
     if (pause)
     {
         #if PLATFORM_LUMIN
         if (MLContacts.IsStarted)
         {
             MLContacts.Stop();
         }
         #endif
     }
     else
     {
         #if PLATFORM_LUMIN
         if (MLDevice.IsReady())
         {
             StartAPI();
         }
         #endif
     }
 }