In order to check whether my "input touch script" should be executed or not, every FixedUpdate I'm checking the UICamera.hoveredObject result. I want that my script is only executed when UICamera.hoveredObject is null.
This is a simplified example of my code:
function FixedUpdate () {
if (Input.touchCount == 1) {
if (Input.GetTouch(0).phase == TouchPhase.Began) {
if (nguiCamera.hoveredObject != null)
word += nguiCamera.hoveredObject.ToString();
else
word += "null";
}
}
}
the string 'word' is displayed OnGUI.
The problem is that UICamera.hoveredObject result is a frame late.
So if I touch over a non NGUI object, word = null,
then touch over NGUI object, word = null,
then touch over NGUI object, word = not null,
then touch over non NGUI object, word = not null,
then touch over non NGUI object, word = null,
What am I doing wrong here? or is there another better solution to identify when an NGUI object is hit or not?