Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Contains(RectTransform)

Checks whether the world-space bounding box of this RectTransform fully contains the world-space bounding box of another RectTransform.
Read time 1 minuteLast updated 6 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public bool Contains(RectTransform other)

Parameters

The RectTransform whose world-space bounds to test against.

Returns

Type

Description

boolTrue if the world-space bounding box of this RectTransform fully contains the bounding box of
other
; false otherwise.

Remarks

Both bounding boxes are axis-aligned and are computed from the four world-space corners via RectTransform.GetWorldRect. Containment is inclusive on all edges, so a RectTransform returns true when tested against itself. Because world-space AABBs are used, a rotated element has an expanded bounding box; two visually overlapping elements may not satisfy containment if their AABBs differ.
Additional Resources: RectTransform.GetWorldRect.