Unity/UI
CalculateRelativeRectTransformBounds
소나무꼴
2021. 8. 4. 18:35
public static Bounds CalculateRelativeRectTransformBounds(Transform root, Transform child)
public static Bounds CalculateRelativeRectTransformBounds(Transform child)
결론은 어렵다..
root가 없으면 는 스크린크기를 기준으로 값이 오는거 같다.
결과는 child의 하위 오브젝트 까지 Bounds 를 검색한 결과가 나온다.
void Update()
{
if(Input.GetKeyUp(KeyCode.A))
{
var b = RectTransformUtility.CalculateRelativeRectTransformBounds(root, a1);
Debug.LogWarning($" {b.min} {b.max} / {b} ");
b = RectTransformUtility.CalculateRelativeRectTransformBounds(root, a2);
Debug.LogWarning($" {b.min} {b.max} / {b} ");
b = RectTransformUtility.CalculateRelativeRectTransformBounds(a1, a2);
Debug.LogWarning($" {b.min} {b.max} / {b} ");
}
}
(-50.0, -150.0, 0.0) (50.0, 50.0, 0.0) / Center: (0.0, -50.0, 0.0), Extents: (50.0, 100.0, 0.0)
(-50.0, -150.0, 0.0) (50.0, -50.0, 0.0) / Center: (0.0, -100.0, 0.0), Extents: (50.0, 50.0, 0.0)
(-50.0, -200.0, 0.0) (50.0, -100.0, 0.0) / Center: (0.0, -150.0, 0.0), Extents: (50.0, 50.0, 0.0)