RectangleContainsScreenPoint no longer works

Hi,

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

somebody can confirm that ?

Hi again,

I found a new bug :frowning:

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 …:frowning:

Have you file a bug report through the editors reporting tool?

Hi,

Yes for the first one case N°660005 ,

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

Use this code on Screen Space - Overlay

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");
        }
    }
}