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;
        }
 public static RectTransformData Lerp(RectTransformData a, RectTransformData b, float amount)
 {
     return(new RectTransformData()
     {
         AnchoredPosition = Vector2.Lerp(a.AnchoredPosition, b.AnchoredPosition, amount),
         AnchorMax = Vector2.Lerp(a.AnchorMax, b.AnchorMax, amount),
         AnchorMin = Vector2.Lerp(a.AnchorMin, b.AnchorMin, amount),
         LocalPosition = Vector3.Lerp(a.LocalPosition, b.LocalPosition, amount),
         Pivot = Vector2.Lerp(a.Pivot, b.Pivot, amount),
         Rotation = Quaternion.Lerp(a.Rotation, b.Rotation, amount),
         Scale = Vector3.Lerp(a.Scale, b.Scale, amount),
         SizeDelta = Vector2.Lerp(a.SizeDelta, b.SizeDelta, amount)
     });
 }
Beispiel #3
0
        public void OnValidate()
        {
            bool isUnInitialized = transformConfigs == null ||
                                   (transformConfigs.Items.Count == 0 &&
                                    transformFallback.Scale == Vector3.zero &&
                                    transformFallback.Rotation.eulerAngles == Vector3.zero &&
                                    transformFallback.AnchoredPosition == Vector2.zero &&
                                    transformFallback.AnchorMin == Vector2.zero &&
                                    transformFallback.AnchorMax == Vector2.zero &&
                                    transformFallback.Pivot == Vector2.zero &&
                                    transformFallback.SizeDelta == Vector2.zero &&
                                    transformFallback.LocalPosition == Vector3.zero);

            if (isUnInitialized)
            {
                if (transformFallback == null)
                {
                    transformFallback = new RectTransformData();
                }

                transformFallback.PullFromTransform(rectTransform);
            }
        }