im trying to use IB = new Rect(a); IB.Contains((Input.mousePosition)) is there any way that i can visualize a rect? trying to find the bounds of an invisible box can be quite tedious.
There's no easy way to visualize it, no. But you can certainly Debug.Log it, and compare the numbers you see to what you would expect (and the mouse position).
Yes. You can have the editor draw gizmos representing the rect. https://docs.unity3d.com/ScriptReference/Gizmos.DrawWireCube.html I have not tested this code but it should work. Just add it to the script with the rect you want to visualize. Code (csharp): void OnDrawGizmos() { // Green Gizmos.color = new Color(0.0f, 1.0f, 0.0f); DrawRect(your_rect_variable); } void OnDrawGizmosSelected() { // Orange Gizmos.color = new Color(1.0f, 0.5f, 0.0f); DrawRect(your_rect_variable); } void DrawRect(Rect rect) { Gizmos.DrawWireCube(new Vector3(rect.center.x, rect.center.y, 0.01f), new Vector3(rect.size.x, rect.size.y, 0.01f)); }
No, no, no. You can do it better: Code (CSharp): Handles.DrawSolidRectangleWithOutline(new[] { transform.position + new Vector3(-neededPlace / 2, 0, -neededPlace / 2), transform.position + new Vector3(neededPlace / 2, 0, -neededPlace / 2), transform.position + new Vector3(neededPlace / 2, 0, neededPlace / 2), transform.position + new Vector3(-neededPlace / 2, 0, neededPlace / 2), }, new Color(0, 1, 0, 0.2f), Color.green); Its solid rect with outline.