/// <summary> /// Transforms a rectangle from the local space of the element to the world space. /// </summary> /// <remarks> /// This element needs to be attached to a panel and must receive a valid <see cref="VisualElement.layout"/>. /// Otherwise, this method may return invalid results. /// </remarks> /// <param name="ele">The element to use as a reference for the local space.</param> /// <param name="r">The rectangle to transform, in local space.</param> /// <returns>A rectangle in the world space.</returns> public static Rect LocalToWorld(this VisualElement ele, Rect r) { if (ele == null) { throw new ArgumentNullException(nameof(ele)); } return(VisualElement.CalculateConservativeRect(ref ele.worldTransformRef, r)); }