private IEnumerator CoAnimate() { float t = 0; isAnimating = true; yield return(null); while (t < CurrentSettings.AnimationTime) { t += Time.deltaTime; float amount = Mathf.SmoothStep(0, 1, t / CurrentSettings.AnimationTime); RectTransformData data = RectTransformData.Lerp(start, end, amount); data.PushToTransform(this.transform as RectTransform); yield return(null); } end.PushToTransform(this.transform as RectTransform); isAnimating = false; // In case that we missed something during animation // simply apply the changes without animation CurrentSettings.IsAnimated = false; SetLayoutHorizontal(); SetLayoutVertical(); CurrentSettings.IsAnimated = true; }
void SetLayout(int axis) { if (axis == 0 && CurrentSettings.HorizontalFit == FitMode.Unconstrained) { return; } if (axis == 1 && CurrentSettings.VerticalFit == FitMode.Unconstrained) { return; } if (isAnimating) { return; } if (CurrentSettings.IsAnimated) { start.PullFromTransform(this.transform as RectTransform); } if (axis == 0) { base.SetLayoutHorizontal(); } else { base.SetLayoutVertical(); } ApplyOffsetToDefaultSize(axis, (axis == 0) ? m_HorizontalFit : m_VerticalFit); if (CurrentSettings.IsAnimated) { end.PullFromTransform(this.transform as RectTransform); start.PushToTransform(this.transform as RectTransform); Animate(); } }