Unity Recttransform contains point
<p>Is there a way to check if Rect transform contains point? Thanks in advance. I tried Bounds.Contains() and RectTransformUtility.RectangleContainsScreenPoint() but that didn't help me</p>

<pre><code>private bool AreCoordsWithinUiObject(Vector2 coords, GameObject gameObj)
{
    Bounds bounds = gameObj.GetComponent&lt;Renderer&gt;().bounds;
    return bounds.Contains(new Vector3(coords.x, coords.y, 0));
}
</code></pre>

<p>This way I have an error "There is no renderer attached to the object" but I've been attached CanvasRenderer to it.</p>

<pre><code>RectTransformUtility.RectangleContainsScreenPoint(gameObj.GetComponent&lt;RectTransform&gt;(), coords);
</code></pre>

<p>This method always return false</p>

<pre><code>if (AreCoordsWithinUiObject(point, lines[i]))
{
    print("contains");
}
</code></pre>

<p>lines is a list of GameObjects</p>

<p><a href="https://i.stack.imgur.com/HvyT1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HvyT1.png" alt="enter image description here"></a></p>