示例#1
0
        /// <summary>
        /// Update the position of the pointer and the pointer probe. Also check to see if the
        /// configuration has been changed to hide the pointer probe.
        /// </summary>
        public virtual void Update()
        {
            if (motionFilter != lastMotionFilter)
            {
#if UNITY_EDITOR
                parentMotionFilter = motionFilter;
#endif
                if (motionFilter != null)
                {
                    motionFilter = Instantiate(motionFilter);
                }
                lastMotionFilter = motionFilter;
            }

#if UNITY_EDITOR
            if (motionFilter != null)
            {
                motionFilter.Copy(parentMotionFilter);
            }
#endif

            Connected = IsConnected;

            if (Probe != null)
            {
                Probe.SetActive(IsEnabled && showProbe);

                if (curLaserPointerMaterial == null)
                {
                    curLaserPointerMaterial = LaserPointerNormalMaterial;
                }

                if (enableLaserPointer)
                {
                    Probe.LaserPointerMaterial = curLaserPointerMaterial;
                }
            }

            if (IsEnabled)
            {
                if (motionFilter != null)
                {
                    motionFilter.UpdateState(WorldPoint);
                }

                InternalUpdate();

                if (Probe != null)
                {
                    Probe?.AlignProbe(Direction, transform.up);
                }
            }
        }
示例#2
0
        public void Update()
        {
            if (motionFilter != lastMotionFilter)
            {
#if UNITY_EDITOR
                parentMotionFilter = motionFilter;
#endif
                if (motionFilter != null)
                {
                    motionFilter = Instantiate(motionFilter);
                }
                lastMotionFilter = motionFilter;
            }

#if UNITY_EDITOR
            if (motionFilter != null)
            {
                motionFilter.Copy(parentMotionFilter);
            }
#endif

            if (ControlMode != lastMode)
            {
                OnModeChange();
                lastMode = ControlMode;
            }

            CheckMouseLock();

            if (ControlMode != Mode.None &&
                (!input.AnyPointerDragging ||
                 Cursor.lockState == CursorLockMode.Locked))
            {
                if (ControlMode == Mode.MouseLocked)
                {
                    CheckMode(
                        Cursor.lockState != CursorLockMode.Locked
                            ? Mode.MouseScreenEdge
                            : ControlMode,
                        disableVertical);
                }
                else if (ControlMode == Mode.MagicWindow)
                {
                    CheckMode(Mode.Touch, true);
                }
                else if (ControlMode == Mode.Gamepad)
                {
                    if (Application.isMobilePlatform)
                    {
                        CheckMode(Mode.Touch, disableVertical);
                    }
                    else
                    {
                        CheckMode(Mode.MouseLocked, disableVertical);
                    }
                }
                else
                {
                    CheckMode(ControlMode, disableVertical);
                }
            }
        }