public void Apply(ILayoutComponentState raw) { var state = raw as UiGridLayoutState; if (state == null) { return; } var rows = (int)Math.Ceiling(state.Count / (float)cellsPerRow); var totalPadding = padding * (rows - 1); var cellHeight = (state.TotalY - totalPadding) / rows; // Layout from the top left var positionY = state.TotalY - cellHeight - state.Row * padding - state.Row * cellHeight + cellHeight / 2f; var positionX = state.Col * padding + state.Col * state.UnitSizeX + state.UnitSizeX / 2f; Service.MoveAndResize(state.Child, new Vector2(state.UnitSizeX, cellHeight), new Vector2(positionX, positionY)); // Step state.Col += 1; if (state.Col >= cellsPerRow) { state.Row += 1; state.Col = 0; } }
public void Complete(ILayoutComponentState raw) { var state = raw as UiVerticalLayoutState; if (state == null) { return; } if (AdjustContainerSize) { var size = RectTransform.sizeDelta; var delta = Mathf.Abs(Mathf.Abs(state.LayoutOffset) - Mathf.Abs(size.y)); if (delta < 0.1f) { return; } if (Direction == UiVerticalLayoutDirection.Down) { RectTransform.offsetMax = new Vector2(RectTransform.offsetMax.x, 0); RectTransform.offsetMin = new Vector2(RectTransform.offsetMax.x, state.LayoutOffset); } else { RectTransform.offsetMax = new Vector2(RectTransform.offsetMax.x, state.LayoutOffset); RectTransform.offsetMin = new Vector2(RectTransform.offsetMax.x, 0); } } }
public void Complete(ILayoutComponentState raw) { var state = raw as UiGridLayoutState; if (state == null) { return; } }
public void Apply(ILayoutComponentState raw) { var state = raw as UiVerticalLayoutState; if (state == null) { return; } var size = Service.GetSize(state.Child); Service.Move(state.Child, new Vector2(0, state.LayoutOffset)); state.LayoutOffset += (size.y + Padding) * state.Direction; }