Save Scroll Position Unity
Save Scroll Position Unity
Code:
public ScrollRect scrollRect;
void OnEnable()
{
scrollRect.onValueChanged.AddListener(scrollRectCallBack);
}
void scrollRectCallBack(Vector2 value)
{
PlayerPrefs.SetFloat("value",value.y);
}
void Start()
{
float laygiatri = PlayerPrefs.GetFloat("value");
scrollRect.verticalNormalizedPosition = laygiatri;
}
void OnDisable()
{
scrollRect.onValueChanged.RemoveListener(scrollRectCallBack);
}
Post a Comment