/// <summary> /// A method to get the pivot position in more coordinate systems. /// </summary> /// <param name="tr"></param> /// <param name="coordinateSystem"></param> public static Vector2 GetPivotPosition(this RectTransform tr, PivotCoordinateSystem coordinateSystem = PivotCoordinateSystem.Default) { switch (coordinateSystem) { case PivotCoordinateSystem.AsChildOfCanvas: return(RtePivotTools.GetCanvasPositionFromLocalPosition(tr, tr.pivot)); } return(tr.pivot); }
/// <summary> /// A method to move the pivot position in more coordinate systems and with the option to only move the pivot without moving the rect. /// Unty moves the rect when setting RectTransform.pivot with this method now you can choose. /// </summary> /// <param name="tr"></param> /// <param name="newPivotPosition">The target pivot position.</param> /// <param name="coordinateSystem"></param> /// <param name="alsoMoveRect">By default unty moves the rect when setting RectTransform.pivot, with this bool now you can choose.</param> public static void SetPivotPosition(this RectTransform tr, Vector2 newPivotPosition, PivotCoordinateSystem coordinateSystem = PivotCoordinateSystem.Default, bool alsoMoveRect = false) { switch (coordinateSystem) { case PivotCoordinateSystem.Default: RtePivotTools.SetPivotPosition(tr, newPivotPosition, alsoMoveRect); break; case PivotCoordinateSystem.AsChildOfCanvas: RtePivotTools.SetPivotPosition(tr, RtePivotTools.GetLocalPositionFromCanvasPosition(tr, newPivotPosition), alsoMoveRect); break; } }