public void ViewMode() { Ray ray = new Ray(transform.position, transform.forward); RaycastHit hitInfo; bool result = Physics.Raycast(ray, out hitInfo, 100f, interest); InterestPoint obj; if (result) { obj = hitInfo.collider.gameObject.GetComponent <InterestPoint>(); if (obj != null) { if (selectedPoint != obj) { if (selectedPoint != null) { selectedPoint.HideText(); selectedPoint = obj; selectedPoint.DisplayText(); } } } } }
// Update is called once per frame void Update() { RaycastHit hit; Ray ray = new Ray(transform.position, transform.forward); Physics.Raycast(ray, out hit); if (hit.transform != null) { if (hit.transform.gameObject.GetComponent <Button>() && (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger) || OVRInput.Get(OVRInput.Button.PrimaryHandTrigger)) || OVRInput.Get(OVRInput.Button.One)) { hit.transform.gameObject.GetComponent <Button>().onClick.Invoke(); } } InterestPoint temp = hit.transform.gameObject.GetComponent <InterestPoint>(); if (temp) { current = temp; current.DisplayText(); } else if (!temp && current) { current.HideText(); } Debug.DrawRay(transform.position, transform.forward, Color.red); }