public static float GetEdgePosition_AsFloat(this RectTransform me, RectTransform.Edge edge) { var relevantPosition = me.position[edge.Axis().CoordinateIndex()]; var distanceToEdge = me.DistanceFromPivotToEdge(edge); var edgePosition = relevantPosition + (distanceToEdge * edge.Direction()); return(edgePosition); }
public static void LineUp( RectTransform leader, IEnumerable <RectTransform> followers, RectTransform.Edge direction, float padding = 0 ) { var previousInLine = leader; foreach (var nextInLine in followers) { nextInLine.Align(direction.Inverse(), previousInLine.GetEdgePosition_AsFloat(direction) + direction.Direction() * padding); previousInLine = nextInLine; } }