private void rayCastGazeRay() { Ray raygaze; RaycastHit hit; Vector2 posGaze = (gazeModel.posGazeLeft + gazeModel.posGazeRight)*0.5f; posGaze.y = Screen.height - posGaze.y; //CheckINput; if(gazeModel.isRunning) { raygaze = Camera.main.ScreenPointToRay(posGaze); } else { raygaze = Camera.main.ScreenPointToRay(Input.mousePosition); } if (Physics.Raycast(raygaze, out hit,Mathf.Infinity,layermask)) { //Debug.Log("Hit Object:" + hit.collider.gameObject.name); MonoBehaviourWithGazeComponent hitMono =hit.collider.gameObject.GetComponent<MonoBehaviourWithGazeComponent>(); if(hitMono != null) { // Save the OldSelection if (oldSelection == null) oldSelection = hitMono; else if(hitMono != oldSelection) { oldSelection.OnObjectExit(); oldSelection = hitMono; } // Invoke Start and Update of the GazeEvent hitMono.OnObjectHit(hit); } } else { if(oldSelection != null) { oldSelection.OnObjectExit(); oldSelection = null; } } }
private void rayCastGazeRay() { Ray raygaze; RaycastHit hit; //CheckINput; if(gazeModel.isRunning) { raygaze = Camera.main.ScreenPointToRay(gazeModel.posGazeRight); } else { raygaze = Camera.main.ScreenPointToRay(Input.mousePosition); } if (Physics.Raycast(raygaze, out hit, 1500f)) { MonoBehaviourWithGazeComponent hitMono =hit.collider.gameObject.GetComponent<MonoBehaviourWithGazeComponent>(); if(hitMono != null) { // Save the OldSelection if (oldSelection == null) oldSelection = hitMono; else if(hitMono != oldSelection) { oldSelection.OnObjectExit(); oldSelection = hitMono; } // Invoke Start and Update of the GazeEvent hitMono.OnObjectHit(hit); } } else { if(oldSelection != null) { oldSelection.OnObjectExit(); oldSelection = null; } } }