public DebugLayout ScrollSingleSelection <T>( IReactiveCollection <T> collection, ICellRW <T> selected, Func <T, string> toString, float takeRelativeLayoutSize = 1) { var currentSelected = InstantiateInLayout(factory.titlePrefab).GetComponentInChildren <Text>(); currentSelected.SetTextContent(selected.Select(v => $"current: {toString(v)}")); var scroll = InstantiateInLayout(factory.scrollPrefab, new DebugLayoutOptions { flexibleSpace = takeRelativeLayoutSize }); Rui.PresentInScrollWithLayout(collection, scroll, show: (s, button) => { button.Show(toString(s), selected.Select(v => object.ReferenceEquals(v, s)), button.connectionSink); button.button.ClickStream().Subscribe(() => selected.value = s); }, prefab: PrefabRef.ToPrefabRef(factory.buttonPrefab), layout: Rui.LinearLayout(forceMainSize: 80)); return(this); }
public DebugLayout ScrollSingleSelection( IReactiveCollection <string> collection, ICellRW <string> selected, float takeRelativeLayoutSize = 1) { var currentSelected = InstantiateInLayout(factory.titlePrefab).GetComponentInChildren <Text>(); currentSelected.SetTextContent(selected.Select(v => $"current: {v}")); var scroll = InstantiateInLayout(factory.scrollPrefab, new DebugLayoutOptions { flexibleSpace = takeRelativeLayoutSize }); Rui.PresentInScrollWithLayout(collection, scroll, PrefabRef.ToPrefabRef(factory.buttonPrefab), (s, button) => { button.Show(s, selected.Select(v => v == s), button.connectionSink); button.addConnection = button.button.ClickStream().Subscribe(() => selected.value = s); }, layout: Rui.LinearLayout(forceMainSize: 80)); return(this); }