BGC Tools
Static Public Member Functions | Static Private Member Functions
BGC.Extensions.RectTransformExtensions Class Reference

Static Public Member Functions

static bool IsChildFullyVisible (this RectTransform rectTransform, RectTransform child)
 
static bool IsChildVisible (this RectTransform rectTransform, RectTransform child)
 

Static Private Member Functions

static int CountCornersVisibleWithin (this RectTransform rectTransform, RectTransform child)
 

Detailed Description

Definition at line 5 of file RectTransformExtensions.cs.

Member Function Documentation

◆ CountCornersVisibleWithin()

static int BGC.Extensions.RectTransformExtensions.CountCornersVisibleWithin ( this RectTransform  rectTransform,
RectTransform  child 
)
inlinestaticprivate

Definition at line 7 of file RectTransformExtensions.cs.

8  {
9  Vector3[] parentCorners = new Vector3[4];
10  rectTransform.GetWorldCorners(parentCorners);
11 
12  Rect worldRect = new Rect(parentCorners[0], parentCorners[2] - parentCorners[0]);
13 
14  Vector3[] childCorners = new Vector3[4];
15  child.GetWorldCorners(childCorners);
16 
17  int visibleCorners = 0;
18  for (var i = 0; i < childCorners.Length; i++)
19  {
20  if (worldRect.Contains(childCorners[i]))
21  {
22  visibleCorners++;
23  }
24  }
25  return visibleCorners;
26  }

◆ IsChildFullyVisible()

static bool BGC.Extensions.RectTransformExtensions.IsChildFullyVisible ( this RectTransform  rectTransform,
RectTransform  child 
)
inlinestatic

Definition at line 29 of file RectTransformExtensions.cs.

30  {
31  return CountCornersVisibleWithin(rectTransform, child) == 4;
32  }
static int CountCornersVisibleWithin(this RectTransform rectTransform, RectTransform child)

◆ IsChildVisible()

static bool BGC.Extensions.RectTransformExtensions.IsChildVisible ( this RectTransform  rectTransform,
RectTransform  child 
)
inlinestatic

Definition at line 35 of file RectTransformExtensions.cs.

36  {
37  return CountCornersVisibleWithin(rectTransform, child) > 0;
38  }
static int CountCornersVisibleWithin(this RectTransform rectTransform, RectTransform child)

The documentation for this class was generated from the following file: