private void UpdateChildren(float movementTime) { float xPos = GetInitalX(); List <GameObject> activeChildren = new List <GameObject>(); foreach (RectTransform child in this.transform) { if (child != null && child.gameObject.activeSelf) { if (!_childMovers.TryGetValue(child, out RectTransformMover mover) || mover == null) { mover = child.GetComponent <RectTransformMover>(); _childMovers.Add(child, mover); } activeChildren.Add(child.gameObject); if (mover != null) { bool wasActive = _activeChildren.Contains(child.gameObject); mover.SetX(xPos, wasActive ? movementTime : -1f, _movementInterpolationType); } else { RectTransformUtils.SetX(child, xPos); } xPos += RectTransformUtils.GetWidth(child) + _spacing; } } _activeChildren = activeChildren; }
private void UpdateChildrenInEditMode() { float xPos = GetInitalX(); foreach (RectTransform child in this.transform) { if (child.gameObject.activeSelf) { RectTransformUtils.SetX(child, xPos); xPos += RectTransformUtils.GetWidth(child) + _spacing; } } }