コード例 #1
0
 public void HandleTarget(TargetingResult targetingResult, IInteractable interactableObject)
 {
     // Place cursor at targeted point, offset slightly along the normal
     transform.position = targetingResult.TargetedPointOnObject + _settings.SurfaceOffset * targetingResult.NormalAtTargetedPoint;
     // Rotate cursor to point along normal at the targeted point
     transform.localRotation = Quaternion.FromToRotation(Vector3.forward, targetingResult.NormalAtTargetedPoint);
     // Choose color based on if the targeted object is interactable or not
     _cursorImage.color = interactableObject != null ? _settings.InteractableColor : _settings.NonInteractableColor;
 }
コード例 #2
0
        private void UpdateAndHandleTargeting()
        {
            // Have the targeter check for a target
            _previousResult = _targeter.AcquireTarget();

            if (_previousResult.TargetedObject != null)
            {
                if (_focusedObject == null || _focusedObject != _previousResult.TargetedObject)
                {
                    HandleNewTargetHit();
                }
                else
                {
                    HandleRepeatHit();
                }
            }
            else
            {
                HandleMiss();
            }
        }