Пример #1
0
 private void Update()
 {
     _annotationLabel.text = "";
     if (_currentInteractive == null)
     {
         for (int i = 0; i < Physics.RaycastNonAlloc(_transform.position, _transform.forward, _raycastHits, 2); i++)
         {
             var interactive = _raycastHits[i].transform.GetComponent <IInteractive>();
             if (interactive != null && interactive.CanInteract)
             {
                 _annotationLabel.text = interactive.Annotation + " (E)";
                 if (Input.GetKeyDown(KeyCode.E))
                 {
                     _currentInteractive = interactive;
                     _currentInteractive.OnStopInteraction += StopInteraction;
                     _playerMover.enabled       = false;
                     _puzzleCameraMover.enabled = true;
                     _puzzleCameraMover.SetTarget(_currentInteractive.CameraPosition);
                     _currentInteractive.Interact();
                 }
             }
         }
     }
     else
     {
         if (Input.GetKeyDown(KeyCode.E))
         {
             _currentInteractive.StopInteraction();
         }
     }
 }