private void _MoveBack(Vector2 v2) { if (_scrollRect != null) { _scrollRect.DONormalizedPos(v2, duration); } }
public void CenterOnItem(RectTransform target) { // Item is here var itemCenterPositionInScroll = GetWorldPointInWidget(mScrollTransform, GetWidgetWorldPoint(target)); // But must be here var targetPositionInScroll = GetWorldPointInWidget(mScrollTransform, GetWidgetWorldPoint(maskTransform)); // So it has to move this distance var difference = targetPositionInScroll - itemCenterPositionInScroll; difference.z = 0f; //clear axis data that is not enabled in the scrollrect if (!mScrollRect.horizontal) { difference.x = 0f; } if (!mScrollRect.vertical) { difference.y = 0f; } var normalizedDifference = new Vector2( difference.x / (mContent.rect.size.x - mScrollTransform.rect.size.x), difference.y / (mContent.rect.size.y - mScrollTransform.rect.size.y)); var newNormalizedPosition = mScrollRect.normalizedPosition - normalizedDifference; if (mScrollRect.movementType != ScrollRect.MovementType.Unrestricted) { newNormalizedPosition.x = Mathf.Clamp01(newNormalizedPosition.x); newNormalizedPosition.y = Mathf.Clamp01(newNormalizedPosition.y); } mScrollRect.DONormalizedPos(newNormalizedPosition, 0.4f).SetEase(Ease.OutCubic); }
public void ShowBlock(int blockIndex) { int total = GetBiggerCommandSequence(); float perc = (float)blockIndex / total; scroll.DONormalizedPos(Vector2.up * perc, 0.25f); }
/// <summary> /// Creates and returns a Tween for the informed component. /// The Tween is configured based on the attribute values of this TweenData file. /// </summary> /// <param name="transform"></param> /// <returns></returns> public Tween GetTween(ScrollRect scroll) { switch (command) { case ScrollRectCommand.NormalizedPos: return(scroll.DONormalizedPos(pos, duration, snapping)); case ScrollRectCommand.HorizontalNormalizedPos: return(scroll.DOHorizontalNormalizedPos(to, duration, snapping)); case ScrollRectCommand.VerticalPos: return(scroll.DOVerticalNormalizedPos(to, duration, snapping)); default: return(null); } }
public override Tween GetTween(UniTween.UniTweenTarget uniTweenTarget) { ScrollRect scroll = (ScrollRect)GetComponent(uniTweenTarget); switch (command) { case ScrollRectCommand.NormalizedPos: return(scroll.DONormalizedPos(pos, duration, snapping)); case ScrollRectCommand.HorizontalNormalizedPos: return(scroll.DOHorizontalNormalizedPos(to, duration, snapping)); case ScrollRectCommand.VerticalPos: return(scroll.DOVerticalNormalizedPos(to, duration, snapping)); default: return(null); } }
public void ShowLastBlock() { scroll.DONormalizedPos(Vector2.up * 0, 0.25f); }