/// <summary> /// Open animation. /// </summary> /// <returns>Animation.</returns> /// <param name="rect">Rect.</param> /// <param name="time">Time.</param> public static IEnumerator Open(RectTransform rect, float time=0.5f) { if (rect!=null) { var layout = rect.GetComponentInParent<EasyLayout.EasyLayout>(); var max_height = rect.rect.height; var end_time = Time.time + time; while (Time.time <= end_time) { var height = Mathf.Lerp(0, max_height, 1 - (end_time - Time.time) / time); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); if (layout!=null) { layout.NeedUpdateLayout(); } yield return null; } //return height back for future use rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, max_height); } }
void EndRecord(EMMotionProperties motion,RectTransform rect){ startRect.ApplyAllToRectTransform( rect, rect.GetComponentInParent<CanvasGroup>() ); }
void Awake() { rect = GetComponent<RectTransform>(); canvas = rect.GetComponentInParent<Canvas>(); }