public void HotSpotControl() { // Cast a ray from the mouse pointer, if in walk mode the ray will be cast from the // centre of the screen. RaycastHit hit; Ray ray; if (!mouseLocked) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); } else { ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); } if (Physics.Raycast(ray, out hit, 200f) && hit.collider.tag == "HotSpot" && !EventSystem.current.IsPointerOverGameObject()) { // Make the current hotspot active if (currentHotspot == null && !hotSpotOpen) { currentHotspot = hit.transform.GetComponentInParent <HotSpot>(); } // If a different hotspot hovered (when cycling through) else if (currentHotspot.name != hit.collider.transform.parent.name) { currentHotspot = hit.transform.GetComponentInParent <HotSpot>(); } // If already active else { // Hover the active HotSpot currentHotspot.StartHover(); // If click is and not on ui, open if (Input.GetMouseButtonDown(0) && !hotSpotOpen) { // Move the walking camera to the hotspot MoveCamera(); OpenInfoPanel(); } // If it is open, close else if (Input.GetMouseButtonDown(0) && hotSpotOpen) { InfoPanelClose(); } } } // Else if the current hotspot is not moused over, deactivate it else if (currentHotspot != null && !hotSpotOpen) { currentHotspot.EndHover(); currentHotspot = null; } else if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) { InfoPanelClose(); } }
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; } }
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; } }
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); } } }