Пример #1
0
    private void HotSpotControl(Ray pointer)
    {
        // Cast a ray from the centre eye position.
        RaycastHit hit;

        // If the ray hits a hotspot
        if (Physics.Raycast(pointer, out hit, 20.0f) && hit.transform.tag == "HotSpot")
        {
            // Make the current hotspot active
            if (currentHotspot == null)
            {
                currentHotspot = hit.transform.GetComponentInParent <HotSpot>();
            }
            // If already active
            else
            {
                // Hover the active HotSpot
                currentHotspot.StartHover();
                shouldOpen = true;
            }
        }
        // Else if the current hotspot is faced away from, deactivate it
        else if (currentHotspot != null && !hotSpotOpen)
        {
            currentHotspot.EndHover();
            currentHotspot = null;
        }
        // Close the open hotspot when the tigger is pressed
        else if (OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger) < 0.1f && hotSpotOpen)
        {
            currentHotspot.CloseHotSpot();
            currentHotspot = null;
            hotSpotOpen    = false;
            dimmer.SetActive(false);
        }
        else
        {
            shouldOpen = false;
        }

        if (OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger) < 0.1f && shouldOpen)
        {
            // Open the hotspot
            currentHotspot.OpenHotSpot();
            hotSpotOpen = true;

            // Move the camera to the hotspot
            MoveCamera("HotSpot");
            shouldOpen = false;
        }
    }
Пример #2
0
    private void HotSpotControl(Ray pointer)
    {
        // Cast a ray from the centre eye position.
        RaycastHit hit;

        // If the ray hits a hotspot
        if (Physics.Raycast(pointer, out hit, 20.0f) && hit.transform.tag == "HotSpot")
        {
            // Make the current hotspot active
            if (currentHotspot == null)
            {
                currentHotspot = hit.transform.GetComponentInParent <HotSpot>();
            }
            // If already active
            else
            {
                // Hover the active HotSpot
                currentHotspot.StartHover();

                // If trigger is pressed, open it
                if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad) && !hotSpotOpen)
                {
                    currentHotspot.OpenHotSpot();
                    hotSpotOpen = true;
                    MoveCamera("HotSpot");
                }
                else if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad) && hotSpotOpen)
                {
                    currentHotspot.CloseHotSpot();
                    currentHotspot = null;
                    hotSpotOpen    = false;
                }
            }
        }
        // Else if the current hotspot is faced away from, deactivate it
        else if (currentHotspot != null && !hotSpotOpen)
        {
            currentHotspot.EndHover();
            currentHotspot = null;
        }
        // Close the open hotspot when the tigger is pressed
        else if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad) && hotSpotOpen)
        {
            currentHotspot.CloseHotSpot();
            currentHotspot = null;
            hotSpotOpen    = false;
        }
    }
Пример #3
0
    private void HotSpotControl(Ray pointer)
    {
        // Cast a ray from the centre eye position.
        RaycastHit hit;

        // If the ray hits a hotspot
        if (Physics.Raycast(pointer, out hit, 20.0f) && hit.transform.tag == "HotSpot")
        {
            // Make the current hotspot active
            if (currentHotspot == null)
            {
                currentHotspot = hit.transform.GetComponentInParent <HotSpot>();
            }
            // If already active
            else
            {
                // Hover the active HotSpot
                currentHotspot.StartHover();

                // Increment the gaze timer.
                lookTimer += Time.deltaTime;

                // If trigger is pressed, open it
                if (OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger) > 0.5f)
                {
                    currentHotspot.OpenHotSpot();
                    hotSpotOpen = true;
                }
                else if (lookTimer > timerDuration)
                {
                    lookTimer = 0f;
                    currentHotspot.OpenHotSpot();
                    hotSpotOpen = true;
                }
            }
        }
        // Else if the current hotspot is faced away from, deactivate it
        else if (currentHotspot != null && !hotSpotOpen)
        {
            currentHotspot.EndHover();
            currentHotspot = null;
        }
        // Close the open hotspot when the tigger is pressed
        else if (OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger) > 0.5f && hotSpotOpen)
        {
            currentHotspot.CloseHotSpot();
            currentHotspot = null;
            hotSpotOpen    = false;
            dimmer.SetActive(false);
        }
        // Close the hotspot if faced away when open for a certain amout of time
        else if (currentHotspot != null && hotSpotOpen)
        {
            // Increment the gaze timer.
            lookTimer += Time.deltaTime;

            if (lookTimer > 5f)
            {
                lookTimer = 0f;
                currentHotspot.CloseHotSpot();
                currentHotspot = null;
                hotSpotOpen    = false;
                dimmer.SetActive(false);
            }
        }
    }