It’s seem that RectangleContainsScreenPoint no longer works correctly with canvas on Screen Space - Overlay
Add Ui canvas to a new scene
Add this little script to the canvas
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
public class test : MonoBehaviour {
void Update(){
if (RectTransformUtility.RectangleContainsScreenPoint( transform as RectTransform,Input.mousePosition,Camera.main)){
Debug.Log ("ok");
}
}
}
It’s log “ok” only on Upper left corner if the canvas is on Screen Space - Overlay , and work correctly if canvas is screen space - camera
If canvas render mode is set to Sceen Space - Camera, the position return by ScreenPointToLocalPointInRectangle is wrong if the property Plane distance is lower than 1.
The class RectTransformUtility is essential, but it seems morethan bugged …
But not for the second because everything is back right after a restart Unity. I’ve noticed when I created the test scene to the bug report. It comes up from time, so I restarted Unity
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
public class test : MonoBehaviour {
void Update(){
if (RectTransformUtility.RectangleContainsScreenPoint( transform as RectTransform,Input.mousePosition,null)){
Debug.Log ("ok");
}
}
}