parent
f49c8564ac
commit
50c41198db
|
@ -1,11 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
/// Credit zero3growlithe
|
||||
/// Credit zero3growlithe
|
||||
/// sourced from: http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-2011648
|
||||
|
||||
/*USAGE:
|
||||
Simply place the script on the ScrollRect that contains the selectable children we'll be scroling to
|
||||
and drag'n'drop the RectTransform of the options "container" that we'll be scrolling.*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
|
@ -170,7 +170,7 @@ namespace UnityEngine.UI.Extensions
|
|||
private void UpdateVerticalScrollPosition(RectTransform selection)
|
||||
{
|
||||
// move the current scroll rect to correct position
|
||||
float selectionPosition = -selection.anchoredPosition.y;
|
||||
float selectionPosition = -selection.anchoredPosition.y - (selection.rect.height * (1 - selection.pivot.y));
|
||||
|
||||
float elementHeight = selection.rect.height;
|
||||
float maskHeight = ScrollWindow.rect.height;
|
||||
|
@ -181,13 +181,13 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
// move the target scroll rect
|
||||
TargetScrollRect.verticalNormalizedPosition +=
|
||||
(offlimitsValue / LayoutListGroup.rect.height) * Time.deltaTime * scrollSpeed;
|
||||
(offlimitsValue / LayoutListGroup.rect.height) * Time.unscaledDeltaTime * scrollSpeed;
|
||||
}
|
||||
|
||||
private void UpdateHorizontalScrollPosition(RectTransform selection)
|
||||
{
|
||||
// move the current scroll rect to correct position
|
||||
float selectionPosition = selection.anchoredPosition.x;
|
||||
float selectionPosition = -selection.anchoredPosition.x - (selection.rect.width * (1 - selection.pivot.x));
|
||||
|
||||
float elementWidth = selection.rect.width;
|
||||
float maskWidth = ScrollWindow.rect.width;
|
||||
|
@ -198,7 +198,7 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
// move the target scroll rect
|
||||
TargetScrollRect.horizontalNormalizedPosition +=
|
||||
(offlimitsValue / LayoutListGroup.rect.width) * Time.deltaTime * scrollSpeed;
|
||||
(offlimitsValue / LayoutListGroup.rect.width) * Time.unscaledDeltaTime * scrollSpeed;
|
||||
}
|
||||
|
||||
private float GetScrollOffset(float position, float listAnchorPosition, float targetLength, float maskLength)
|
||||
|
|
Loading…
Reference in New Issue