/// <summary> /// Abstracted function which allows sliding UI elements on or offscreen if they are defined as TweenedElements /// </summary> /// <param name="element">The element to be tweened</param> /// <param name="screenState">Whether the object should be on or off screen at the end of the tween</param> /// <param name="onComplete">Function on callback</param> /// <param name="tweenType">Overides the twwn type</param> public void SlideElement(TweenedElement element, ScreenState screenState, Action onComplete = null, LeanTweenType tweenType = LeanTweenType.easeInOutCubic) { LeanTween.move(element.m_RectTransform, element.m_Cache[(int)screenState], m_TweenSpeed).setEase(tweenType).setOnComplete(onComplete); }
/// <summary> /// Caches the positions of an TweenedElement object for tweening /// </summary> /// <param name="tweenedElement">The element whose positions are to be cached</param> /// <param name="offset">The offset for when the element is offscreen</param> private void SetCachesAndPosition(TweenedElement tweenedElement, Vector2 offset) { tweenedElement.m_Cache[0] = tweenedElement.m_RectTransform.anchoredPosition; tweenedElement.m_Cache[1] = tweenedElement.m_Cache[0] + offset; tweenedElement.m_RectTransform.anchoredPosition = tweenedElement.m_Cache[1]; }