/// <summary> /// Checks if the object hit by the ray cast is a pointable. /// </summary> /// <param name="hit"></param> private void CheckHitPointable(RaycastHit hit) { // if the object hit by the raycast is a pointable object if (hit.collider.GetComponent <Pointable>() && hit.collider.GetComponent <Pointable>().isPointable) { // if there was no pointed at object if (pointingAt == null) { pointingAt = hit.collider.GetComponent <Pointable>(); pointingAt.pointEvents.pointedAt.Invoke(); } else if (pointingAt != null && pointingAt != hit.collider.GetComponent <Pointable>()) { // if there was a pointed at object, but this is a different one pointingAt.pointEvents.unpointedAt.Invoke(); pointingAt = hit.collider.GetComponent <Pointable>(); pointingAt.pointEvents.pointedAt.Invoke(); } // set the second line point to hit linePoints[1] = hit.point; // if no pointables are being hit by the pointer } else { ClearPointedObject(); } }
/// <summary> /// Clears the pointed at object. /// </summary> private void ClearPointedObject() { if (pointingAt != null) { pointingAt.pointEvents.unpointedAt.Invoke(); pointingAt = null; } }