private static int CountCornersVisibleFrom(this RectTransform rectTransform, Canvas canvas) { Rect screenBounds = new Rect(0f, 0f, Screen.width, Screen.height); Rect rect = RectTransformExtension.GetScreenRect(rectTransform, canvas); return(rect.Corners().Count(screenBounds.Contains)); }