public bool TryConvertToWorldSpace(Transform inTransform, Camera inWorldCamera, TransformOffset inOffset, out Vector3 outWorld) { if (inWorldCamera == CanvasCamera) { outWorld = inOffset.EvaluateWorld(inTransform); return(true); } Vector3 screenSpace = TransformHelper.ScreenPosition(inTransform, inWorldCamera, inOffset); return(RectTransformUtility.ScreenPointToWorldPointInRectangle(CanvasSpace, screenSpace, CanvasCamera, out outWorld)); }
/// <summary> /// Returns the screen position of this transform, offset by the given offsets, using the given camera. /// </summary> static public Vector2 ScreenPosition(this Transform inTransform, Camera inCamera, TransformOffset inOffset) { return(RectTransformUtility.WorldToScreenPoint(inCamera, inOffset.EvaluateWorld(inTransform))); }