示例#1
0
        private void Update()
        {
            _scaleAction.ObjectToScale = _collisionTrigger.CollidedTransform;

            if (_leftButtonDownTrigger.IsValid() && (_collisionTrigger.IsValid() || _canScaleRight))
            {
                _canScaleLeft = true;
            }

            if (_rightButtonDownTrigger.IsValid() && (_collisionTrigger.IsValid() || _canScaleLeft))
            {
                _canScaleRight = true;
            }

            if (_leftButtonUpTrigger.IsValid())
            {
                _canScaleLeft = false;
            }

            if (_rightButtonUpTrigger.IsValid())
            {
                _canScaleRight = false;
            }

            _scaleAction.Update(_canScaleLeft && _canScaleRight);
        }
示例#2
0
 void LateUpdate()
 {
     // Properly erase all even with the 24 limits from the shader.
     if (_clearAllTrigger.IsValid())
     {
         _drawingAction.EraseAll();
     }
     _drawingAction.Update(_drawingTrigger.GetOutput() > 0);
 }
        private void Update()
        {
            if (_buttonTrigger.IsValid() && !_pressedState)
            {
                var mats = _targerRenderer.sharedMaterials;
                _defaultMaterial = mats[0];
                mats[0]          = _newMaterial;
                _targerRenderer.sharedMaterials = mats;
                _pressedState = true;
            }

            if (!_buttonTrigger.IsValid() && _pressedState)
            {
                var mats = _targerRenderer.sharedMaterials;
                mats[0] = _defaultMaterial;
                _targerRenderer.sharedMaterials = mats;
                _pressedState = false;
            }
        }
        private void Update()
        {
            if (_activeMenuTrigger.IsValid())
            {
                if (_isDesactived)
                {
                    _initialSelectionPose = _pointingDevice.GetOutput().transform;
                    transform.position    = _pointingDevice.GetOutput().transform.position;
                    float rotX = _pointingDevice.GetOutput().transform.rotation.eulerAngles.x;
                    float rotY = _pointingDevice.GetOutput().transform.rotation.eulerAngles.y;
                    transform.rotation  = Quaternion.Euler(rotX, rotY, 0.0f);
                    transform.position += _pointingDevice.GetOutput().transform.forward *_distanceToMenu;

                    _menuPlane = new Plane(_pointingDevice.GetOutput().transform.forward, transform.position);

                    // The UI will appears just behind the initial center pose.
                    Vector3 visualUIInitialPos = transform.position;
                    _uiTransitionOffset = _pointingDevice.GetOutput().transform.forward *_initialUIdistance;
                    visualUIInitialPos += _uiTransitionOffset;

                    for (int i = 0; i < _activeMenuObjects.Count; i++)
                    {
                        _activeMenuObjects[i].gameObject.SetActive(true);
                        _activeMenuObjects[i].SetVisualStartingPoint(visualUIInitialPos);
                    }
                    _isDesactived = false;
                }
                else
                {
                    int hitIndex = GetClosestItem(_activeMenuObjects);
                    if (hitIndex != -1)
                    {
                        NewActiveItem(hitIndex);
                    }
                }
            }
            else if (!_isDesactived)
            {
                if (_activeItem != -1 && _activeMenuObjects[_activeItem].GetType() == typeof(MarkerMenuInteractable))
                {
                    var endItem = _activeMenuObjects[_activeItem] as MarkerMenuInteractable;
                    endItem.OnMarkerMenuRelease.Invoke();
                }
                for (int i = 0; i < _activeMenuObjects.Count; i++)
                {
                    _activeMenuObjects[i].GetComponentInChildren <Transform>().gameObject.SetActive(false);
                    _activeMenuObjects[i].gameObject.SetActive(false);
                }
                _isDesactived = true;
                _activeItem   = -1;
                _activeMenuObjects.Clear();
                _activeMenuObjects.AddRange(_layerOneMenuObjects);
                _previousActiveObjects = new List <List <MarkerMenuItem> >();
            }
        }
示例#5
0
 private void Update()
 {
     if (_teleportBeam == null)
     {
         _teleportBeam = _showBeamAction.TeleportBeam;
     }
     _showBeamAction.Update(_showBeamTrigger.IsValid() && !_teleporting);
     if (_teleportTrigger.IsValid() && _showBeamAction.TeleportBeam.IsValid() && _coroutine == null)
     {
         _coroutine = _teleportBeam.StartCoroutine(FadeAndTeleport());
     }
 }
示例#6
0
 private void Update()
 {
     if (_undoTrigger.IsValid())
     {
         Undo();
     }
     else if (_redoTrigger.IsValid())
     {
         Redo();
     }
     else if (_undoAllTrigger.IsValid())
     {
         bool undoAll;
         do
         {
             undoAll = Undo();
         }while (undoAll);
     }
 }
示例#7
0
        private void Update()
        {
            if (_calibrationPoints.Count > 3)
            {
                CalibrationMode = false;
                return;
            }

            var unconfirmedPoint = _stylusTransform.GetOutput().position;

            // Position first dot under Stylus.
            PositionDotUnderPen(_dotUnderPen, unconfirmedPoint);

            switch (_calibrationPoints.Count)
            {
            case 0:
                // Add new point to list if button pressed.
                if (_newPointTrigger.IsValid())
                {
                    _calibrationPoints.Add(_stylusTransform.GetOutput().position);
                }
                break;

            case 1:
                // Draw dotted line between first point and Stylus.
                _dashedLine.gameObject.SetActive(true);
                var linePoints = new Vector3[] { _calibrationPoints[0], unconfirmedPoint };
                DrawClosedPolygon(_dashedLine, linePoints);

                // Add new point to list if button pressed.
                if (_newPointTrigger.IsValid())
                {
                    _calibrationPoints.Add(_stylusTransform.GetOutput().position);
                }
                break;

            case 2:
                // Draw rectangle constrained by Stylus position.
                var thirdPoint  = GetProjectionOnPlane(unconfirmedPoint, _calibrationPoints[1], _calibrationPoints[1] - _calibrationPoints[0]);
                var fourthPoint = GetProjectionOnPlane(unconfirmedPoint, _calibrationPoints[0], _calibrationPoints[0] - _calibrationPoints[1]);

                Vector3[] rectPoints = { _calibrationPoints[0], _calibrationPoints[1], thirdPoint, fourthPoint };
                DrawClosedPolygon(_dashedLine, rectPoints);

                // Add last two points to list if button pressed.
                if (_newPointTrigger.IsValid())
                {
                    _calibrationPoints.Add(thirdPoint);
                    _calibrationPoints.Add(fourthPoint);

                    // The Main camera's forward direction is used to disambiguate between the four possible orientation.
                    FinishPositioningRectangle(_drawingPlane, _calibrationPoints, Camera.main.transform.forward);

                    if (_callback != null)
                    {
                        _callback(_drawingPlane);
                    }
                }
                break;

            default:
                Debug.LogError("Calibration has illegal number of points: " + _calibrationPoints.Count);
                break;
            }
        }
示例#8
0
        private void Update()
        {
            _followObjectPositionAction.Follower    = _world;
            _followTwoObjectPositionAction.Follower = _world;
            _followObjectRotationAction.Follower    = _world;
            _rotateAction.ObjectToRotate            = _world;
            _scaleAction.ObjectToScale = _world;

            Transform targetToFollow = _grabButtonTrigger.TrackedDeviceProvider.GetOutput().transform;

            _followObjectPositionAction.TargetToFollow = targetToFollow;
            _followObjectRotationAction.TargetToFollow = targetToFollow;

            Transform secondTargetToFollow = _rotateScaleAndMoveButtonTrigger.TrackedDeviceProvider.GetOutput().transform;

            _followTwoObjectPositionAction.FirstTargetToFollow  = targetToFollow;
            _followTwoObjectPositionAction.SecondTargetToFollow = secondTargetToFollow;

            if (_grabButtonTrigger.IsValid())
            {
                if (!_collisionTrigger.IsValid() && !_grabbing && !_grabButtonDown)
                {
                    _grabbing = true;
                }

                _grabButtonDown = true;
            }
            else if (_grabButtonDown)
            {
                _grabButtonDown = false;
                _grabbing       = false;
            }

            if (_2ControllerPosition)
            {
                if (!_doubleGrabbing && _grabbing && _rotateScaleAndMoveButtonTrigger.IsValid())
                {
                    _doubleGrabbing = true;
                }
                else if (!_rotateScaleAndMoveButtonTrigger.IsValid() && _doubleGrabbing)
                {
                    _doubleGrabbing = false;
                }
            }

            if (_2ControllerScale)
            {
                if (!_scaling && _grabbing && _grabButtonTrigger.IsValid() && _rotateScaleAndMoveButtonTrigger.IsValid())
                {
                    _scaling = true;
                }
                else if ((!_rotateScaleAndMoveButtonTrigger.IsValid()) && _scaling)
                {
                    _scaling = false;
                }

                if (_scaling)
                {
                    _scaleAction.ScaleValueX = _distanceProvider.GetOutput();
                    _scaleAction.ScaleValueY = _distanceProvider.GetOutput();
                    _scaleAction.ScaleValueZ = _distanceProvider.GetOutput();
                }

                _scaleAction.Update(_scaling);
            }

            if (_2ControllerRotate)
            {
                _followObjectRotationAction.FollowTargetRotation = 0;

                if (!_rotating && _grabbing && _grabButtonTrigger.IsValid() && _rotateScaleAndMoveButtonTrigger.IsValid())
                {
                    _rotating = true;
                    _rotationAngleProvider.Init();
                }
                else if ((!_rotateScaleAndMoveButtonTrigger.IsValid()) && _rotating)
                {
                    _rotating = false;
                }

                if (_rotating)
                {
                    _rotateAction.RotationValue = _rotationAngleProvider.GetOutput();
                }

                _rotateAction.Update(_rotating);
            }

            _followObjectPositionAction.Update(_grabbing);
            _followObjectRotationAction.Update(_rotating || _grabbing);
            _followTwoObjectPositionAction.Update(_doubleGrabbing);
        }
示例#9
0
        private void Update()
        {
            Transform targetToFollow = _grabButtonTrigger.TrackedDeviceProvider.GetOutput().transform;

            _followObjectPositionAction.TargetToFollow = targetToFollow;
            _followObjectRotationAction.TargetToFollow = targetToFollow;

            if (_highlightGrabTarget && !_grabbing)
            {
                if (_collisionTrigger.IsValid())
                {
                    if (_collisionTrigger.CollidedTransform.GetComponent <CollisionInteractable>().ContainsTag(_highlightTag))
                    {
                        _highlightAction.ObjectToHighlight = _collisionTrigger.CollidedTransform;
                        _highlightAction.SetCurrentHighlightOutline(_baseHighlightSize);
                    }
                }
                _highlightAction.Update(_collisionTrigger.IsValid());
            }


            if (_grabButtonTrigger.IsValid())
            {
                if (_collisionTrigger.IsValid() && !_grabbing && !(!_allowBufferedGrabbing && _buttonDown))
                {
                    _followObjectPositionAction.Follower = _collisionTrigger.CollidedTransform;
                    _followObjectRotationAction.Follower = _collisionTrigger.CollidedTransform;
                    _grabbing = true;

                    if (_highlightGrabTarget && _collisionTrigger.CollidedTransform.GetComponent <CollisionInteractable>().ContainsTag(EInteractable.Highlight))
                    {
                        _highlightAction.SetCurrentHighlightOutline(_grabHighlightSize);
                    }
                }

                _buttonDown = true;
            }
            else if (_buttonDown)
            {
                _buttonDown = false;
                _grabbing   = false;
                if (_highlightGrabTarget)
                {
                    _highlightAction.SetCurrentHighlightOutline(_baseHighlightSize);
                }
            }

            if (_2ControllerScale)
            {
                if (!_scaling && _grabbing && _scaleButtonTrigger.IsValid())
                {
                    _scaling = true;
                    _scaleAction.ObjectToScale = _collisionTrigger.CollidedTransform;
                }
                else if ((!_scaleButtonTrigger.IsValid() || !_grabbing) && _scaling)
                {
                    _scaling = false;
                }

                if (_scaling)
                {
                    _scaleAction.ScaleValueX = _distanceProvider.GetOutput();
                    _scaleAction.ScaleValueY = _distanceProvider.GetOutput();
                    _scaleAction.ScaleValueZ = _distanceProvider.GetOutput();
                }

                _scaleAction.Update(_scaling);
            }

            _followObjectPositionAction.Update(_grabbing);
            _followObjectRotationAction.Update(_grabbing);
        }
示例#10
0
 private void Update()
 {
     _hapticAction.Update(_hapticTrigger.IsValid());
 }
示例#11
0
 private void Update()
 {
     _printAction.Update(_printTrigger.IsValid());
 }
示例#12
0
        private void LateUpdate()
        {
            bool block = _blockRaycastTriggers.Any(propertyStateTrigger => propertyStateTrigger.IsValid());

            if (!block && _raycastTrigger.IsValid() && _raycastTrigger.RaycastHit.collider.gameObject.GetComponent <UIInteractable>() != null)
            {
                IsRaycasting = true;
                RaycastHit     hit = _raycastTrigger.RaycastHit;
                UIInteractable newHoveredElement = hit.collider.gameObject.GetComponent <UIInteractable>();

                // Did we hover a new element?
                if (newHoveredElement != _hoveredElement)
                {
                    // Hover out on the previous hovered element.
                    if (_hoveredElement != null)
                    {
                        _hoveredElement.HoverOut();
                    }

                    if (newHoveredElement.RaycastInteraction)
                    {
                        _line.gameObject.SetActive(true);
                    }
                    else
                    {
                        _line.gameObject.SetActive(false);
                    }

                    _hoveredElement = newHoveredElement;
                    Debug.Assert(_hoveredElement != null, "We asked for colliders attached to game objects with ClickableInteractable and now we can't find it?");

                    _hoveredElement.HoverIn(_onButtonTrigger.IsValid());
                }

                if (_raycastCollisionTrigger.IsValid())
                {
                    _hoveredElement.Hover(_raycastCollisionTrigger.RaycastHit, transform, true);
                }
                else
                {
                    _hoveredElement.Hover(_raycastCollisionTrigger.RaycastHit, transform, false);
                }

                // Update ray.
                Vector3[] positions = { transform.position, transform.position + transform.forward * (hit.distance + _raycastTrigger.Offset) };
                _line.SetPositions(positions);

                // Pass button events.
                if (_onButtonDownTrigger.IsValid())
                {
                    _hoveredElement.ButtonDown();
                }
                if (_onButtonTrigger.IsValid())
                {
                    _hoveredElement.Button(hit);
                }
                if (_onButtonUpTrigger.IsValid())
                {
                    _hoveredElement.ButtonUp();
                }
            }
            else
            {
                IsRaycasting = false;

                // Did we just leave an element?
                if (_hoveredElement != null)
                {
                    _line.gameObject.SetActive(false);
                    _hoveredElement.HoverOut();
                    _hoveredElement = null;
                }
            }
        }