using System.Collections.Generic; using UnityEngine; namespace UnityEngine.UI.Extensions.Examples { public class Example03ScrollView : FancyScrollView { [SerializeField] ScrollPositionController scrollPositionController = null; void Awake() { scrollPositionController.OnUpdatePosition(p => UpdatePosition(p)); SetContext(new Example03ScrollViewContext { OnPressedCell = OnPressedCell }); } public void UpdateData(List data) { cellData = data; scrollPositionController.SetDataCount(cellData.Count); UpdateContents(); } void OnPressedCell(Example03ScrollViewCell cell) { scrollPositionController.ScrollTo(cell.DataIndex, 0.4f); Context.SelectedIndex = cell.DataIndex; UpdateContents(); } } }