Esempio n. 1
0
 public override void OnPointerExit(GameObject previousObject)
 {
     ReticleDistanceInMeters = maxReticleDistance;
     ReticleInnerAngle       = RETICLE_MIN_INNER_ANGLE;
     ReticleOuterAngle       = RETICLE_MIN_OUTER_ANGLE;
     target = null;
 }
Esempio n. 2
0
 public void stopFilling()
 {
     filling     = false;
     isFilled    = false;
     interactive = null;
     for (int i = 0; i < m_Images.Length; i++)
     {
         m_Images[i].fillAmount = 0;
     }
 }
Esempio n. 3
0
 public void fillInTime(VRInteractive interactive)
 {
     for (int i = 0; i < m_Images.Length; i++)
     {
         m_Images[i].fillAmount = 0;
     }
     isFilled         = false;
     filling          = true;
     this.interactive = interactive;
 }
Esempio n. 4
0
        private void DeactiveLastInteractible()
        {
            if (lastInteractible == null)
            {
                return;
            }

            lastInteractible.ReticleExit();
            lastInteractible = null;
        }
Esempio n. 5
0
    private bool SetPointerTarget(RaycastResult _target, bool interactive)
    {
        if (base.PointerTransform == null)
        {
            Debug.LogWarning("Cannot operate on a null pointer transform");
            return(false);
        }
        target = _target.gameObject.GetComponent <VRInteractive>();
        Vector3 targetLocalPosition = base.PointerTransform.InverseTransformPoint(_target.worldPosition);

        ReticleDistanceInMeters =
            Mathf.Clamp(targetLocalPosition.z, RETICLE_DISTANCE_MIN, maxReticleDistance);
        if (interactive)
        {
            ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE + RETICLE_GROWTH_ANGLE;
            ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE + RETICLE_GROWTH_ANGLE;
        }
        else
        {
            ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE;
            ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE;
        }
        return(true);
    }
Esempio n. 6
0
        private void EyeRaycast()
        {
            // Show the debug ray if required
            if (isShow)
            {
                Debug.DrawRay(m_Camera.position, m_Camera.forward * debugRayLength, Color.blue, debugRayDuration);
            }

            // Create a ray that points forwards from the camera.
            Ray ray = new Ray(m_Camera.position, m_Camera.forward);

            if (reticle.isVR)
            {
                ray = m_Camera.GetComponent <Camera>().ScreenPointToRay(reticle.m_Dots[1].position);
            }
            RaycastHit hit;

            // Do the raycast forweards to see if we hit an interactive item
            if (Physics.Raycast(ray, out hit, rayLength, ~exclusionLayers))
            {
                VRInteractive interactible = hit.collider.GetComponent <VRInteractive>(); //attempt to get the VRInteractiveItem on the hit object
                currentInteractible = interactible;

                // If we hit an interactive item and it's not the same as the last interactive item, then call Over
                if (interactible && currentInteractible != lastInteractible)
                {
                    if (reticle)
                    {
                        reticle.fillInTime(interactible);
                        reticle.Show();
                    }

                    interactible.ReticleEnter();
                }
                else if (interactible == null)
                {
                    if (reticle)
                    {
                        reticle.stopFilling();
                        reticle.Hide();
                    }
                }

                // Deactive the last interactive item
                if (interactible != lastInteractible)
                {
                    DeactiveLastInteractible();
                }

                lastInteractible = interactible;

                if (OnRaycasthit != null)
                {
                    OnRaycasthit(hit);
                }
            }
            else
            {
                // Nothing was hit, deactive the last interactive item.
                DeactiveLastInteractible();
                currentInteractible = null;

                // Position the reticle at default distance.
                if (reticle)
                {
                    reticle.stopFilling();
                    reticle.Hide();
                }
            }
        }