/// <summary> /// Collapse animation. /// </summary> /// <param name="notify">Notify.</param> static public IEnumerator AnimationCollapseUnscaledTime(Notify notify) { var rect = notify.transform as RectTransform; var layout = notify.GetComponentInParent <EasyLayout.EasyLayout>(); var max_height = rect.rect.height; var speed = 200f; var time = max_height / speed; var end_time = Time.unscaledTime + time; while (Time.unscaledTime <= end_time) { var height = Mathf.Lerp(max_height, 0, 1 - (end_time - Time.unscaledTime) / time); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); if (layout != null) { layout.UpdateLayout(); } yield return(null); } //return height back for future use rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, max_height); }
/// <summary> /// Base collapse animation. /// </summary> /// <param name="notify">Notify.</param> /// <param name="isHorizontal">Is horizontal?</param> /// <param name="speed">Animation speed in points per second.</param> /// <returns>Returns animations.</returns> public static IEnumerator AnimationCollapseBase(Notify notify, bool isHorizontal, float speed) { var rect = notify.transform as RectTransform; var layout = notify.GetComponentInParent <EasyLayout>(); var axis = isHorizontal ? RectTransform.Axis.Horizontal : RectTransform.Axis.Vertical; var base_size = isHorizontal ? rect.rect.width : rect.rect.height; var time = base_size / speed; var end_time = Utilites.GetTime(notify.unscaledTime) + time; while (Utilites.GetTime(notify.unscaledTime) <= end_time) { var t = 1f - ((end_time - Utilites.GetTime(notify.unscaledTime)) / time); var size = Mathf.Lerp(base_size, 0f, t); rect.SetSizeWithCurrentAnchors(axis, size); if (layout != null) { layout.NeedUpdateLayout(); } yield return(null); } // return height back for future use rect.SetSizeWithCurrentAnchors(axis, base_size); }
/// <summary> /// Base slide animation. /// </summary> /// <param name="notify">Notify.</param> /// <param name="isHorizontal">Is horizontal slide?</param> /// <param name="direction">Slide direction.</param> /// <param name="speed">Speed.</param> /// <param name="animateOthers">Animate other notifications.</param> /// <returns>Animation.</returns> public static IEnumerator AnimationSlideBase(Notify notify, bool isHorizontal, float direction, float speed, bool animateOthers = true) { var replacement = GetReplacement(notify); var layout_element = Utilites.GetOrAddComponent <LayoutElement>(notify); layout_element.ignoreLayout = true; var layout = notify.GetComponentInParent <EasyLayout>(); var rect = notify.transform as RectTransform; var base_size = isHorizontal ? rect.rect.width : rect.rect.height; var base_pos = rect.anchoredPosition; var time = base_size / speed; var end_time = Utilites.GetTime(notify.unscaledTime) + time; var axis = isHorizontal ? RectTransform.Axis.Horizontal : RectTransform.Axis.Vertical; while (Utilites.GetTime(notify.unscaledTime) <= end_time) { if (!animateOthers) { base_pos = replacement.anchoredPosition; } var t = 1 - ((end_time - Utilites.GetTime(notify.unscaledTime)) / time); var size = Mathf.Lerp(0, base_size, t); rect.anchoredPosition = isHorizontal ? new Vector2(base_pos.x + (size * direction), base_pos.y) : new Vector2(base_pos.x, base_pos.y + (size * direction)); if (animateOthers) { replacement.SetSizeWithCurrentAnchors(axis, base_size - size); if (layout != null) { layout.NeedUpdateLayout(); } } yield return(null); } layout_element.ignoreLayout = false; Replacements.Push(replacement); replacement.gameObject.SetActive(false); replacement.SetSizeWithCurrentAnchors(axis, base_size); if (layout != null) { layout.NeedUpdateLayout(); } }
// Token: 0x06004859 RID: 18521 RVA: 0x00183F18 File Offset: 0x00182318 public static IEnumerator AnimationCollapse(Notify notify) { RectTransform rect = notify.GetComponent <RectTransform>(); EasyLayout.EasyLayout layout = notify.GetComponentInParent <EasyLayout.EasyLayout>(); float max_height = rect.rect.height; float speed = 200f; float time = max_height / speed; float end_time = Time.time + time; while (Time.time <= end_time) { float height = Mathf.Lerp(max_height, 0f, 1f - (end_time - Time.time) / time); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); if (layout != null) { layout.UpdateLayout(); } yield return(null); } rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, max_height); yield break; }
/// <summary> /// Collapse animation. /// </summary> /// <param name="notify">Notify.</param> public static IEnumerator AnimationCollapse(Notify notify) { var rect = notify.GetComponent<RectTransform>(); var layout = notify.GetComponentInParent<EasyLayout.EasyLayout>(); var max_height = rect.rect.height; var speed = 200f;//pixels per second var time = max_height / speed; var end_time = Time.time + time; while (Time.time <= end_time) { var height = Mathf.Lerp(max_height, 0, 1 - (end_time - Time.time) / time); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); if (layout!=null) { layout.UpdateLayout(); } yield return null; } //return height back for future use rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, max_height); }