Created
June 19, 2017 15:33
-
-
Save marcelschmidtdev/bd42965967cd02a9f3b286ab4dbbf8cc to your computer and use it in GitHub Desktop.
Center element of scroll list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
public static class ScrollRectExtensions | |
{ | |
public static void SnapTo (this ScrollRect rect, Transform target) | |
{ | |
rect.content.anchoredPosition = rect.transform.InverseTransformPoint (rect.content.position) - rect.transform.InverseTransformPoint (target.position); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment