using System;
using UniRx;
using UnityEngine;
using UnityEngine.UI;

public class ScrollViewSlider : MonoBehaviour
{
    [SerializeField] private ScrollRect scrollRect;
    [SerializeField] private Slider verticalSlider;

    private void Start()
    {
        verticalSlider.direction = Slider.Direction.BottomToTop;
        verticalSlider.OnValueChangedAsObservable().Subscribe(x =>
        {
            scrollRect.verticalNormalizedPosition = x;
        }).AddTo(this);
        scrollRect.OnValueChangedAsObservable().Subscribe(x =>
        {
            verticalSlider.value = x.y;
        }).AddTo(this);
        scrollRect.verticalNormalizedPosition = 1;
    }
}
