Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

RectTransform.Contains

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool Contains(RectTransform other);

Parameters

Parameter Description
other The RectTransform whose world-space bounds to test against.

Returns

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

Description

Checks whether the world-space bounding box of this RectTransform fully contains the world-space bounding box of another RectTransform.

Both bounding boxes are axis-aligned and are computed from the four world-space corners via 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: GetWorldRect.